win32释放资源
2021-01-03 03:28
标签:make oba bsp err pen lob free resource show win32释放资源 标签:make oba bsp err pen lob free resource show 原文地址:https://www.cnblogs.com/icyvalley/p/13212208.htmlBOOL FreeMyResource(UINT uResouceName,char *szResourceType,char *szFileName)
{
HRSRC hRsrc = ::FindResource(NULL,MAKEINRESOURCE(uResouceName),szResourceType);
if(NULL == hRsrc)
{
ShowError("FindResource");
return FALSE;
}
DWORD dwSize = ::SizeofResource(NULL,hRsrc);
if(0 >= dwSize)
{
ShowError("SizeofResource");
return FALSE;
}
HGLOBAL hGlobal = ::LoadResource(NULL,hRsrc);
if(NULL == hGlobal)
{
ShowError("LoadResource");
return FALSE;
}
LPVOID lpVoid = ::LockResource(hGlobal);
if(NULL == lpVoid)
{
ShowError("LockResource");
return FALSE;
}
FILE *fp = NULL;
fopen_s(&fp,szFileName,"wb+");
if (NULL == fp)
{
ShowError("OpenFileFailed");
return FALSE;
}
fwrite(lpVoid,sizeof(char),dwSize,fp);
fclose(fp);
return TRUE;
}