Created
June 29, 2014 23:55
-
-
Save lookat23/48404a1706861b062994 to your computer and use it in GitHub Desktop.
加载资源,然后写成文件
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HINSTANCE instance = AfxGetInstanceHandle(); | |
// 定位资源 | |
HRSRC hRsrc = FindResource(instance, MAKEINTRESOURCE(IDR_FILE1), _T("File")); | |
// 获取资源大小 | |
DWORD dwSize = SizeofResource(instance, hRsrc); | |
assert(dwSize != 0); | |
// 加载资源 | |
HGLOBAL hGlobal = LoadResource(instance, hRsrc); | |
assert(hGlobal != NULL); | |
// 锁定资源 | |
LPVOID pBuffer = LockResource(hGlobal); | |
assert(pBuffer != NULL); | |
FILE* f = fopen("d:\\aa.exe","wb"); | |
assert(f != NULL); | |
fwrite(pBuffer, dwSize, 1, f); | |
fclose(f); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment