c++ - 在 Windows 模塊中,C++ 從資源中提取文件

  显示原文与译文双语对照的内容
72 2

下面的代碼執行,但它只提取一個空點陣圖文件。關於它是什麼問題的任何想法?

void Extract(WORD wResId, LPSTR lpszOutputPath)
{//example: Extract(IDB_BITMAP1,"Redrose.bmp");
 HRSRC hrsrc = FindResource(NULL, MAKEINTRESOURCE(wResId), RT_BITMAP);
 HGLOBAL hLoaded = LoadResource( NULL,hrsrc);
 LPVOID lpLock = LockResource( hLoaded);
 DWORD dwSize = SizeofResource(NULL, hrsrc);
 HANDLE hFile = CreateFile (lpszOutputPath,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
 DWORD dwByteWritten;
 WriteFile(hFile, lpLock, dwSize, &dwByteWritten, NULL);
 CloseHandle(hFile);
 FreeResource(hLoaded);
}
时间:原作者:0个回答

...