呵呵,自己来回答 CFile f; //This is the file which will be used as an exe file char* pFileName = "Execution.exe"; if( !f.Open( pFileName, CFile::modeCreate | CFile::modeWrite, NULL ) ) { AfxMessageBox("Can not create file!"); return 0; } CString path = f.GetFilePath(); HGLOBAL hRes; HRSRC hResInfo; //Get the instance handle for this app HINSTANCE insApp = AfxGetInstanceHandle(); //find the handle for the EXE resource file hResInfo = FindResource(insApp,(LPCSTR)IDR_EXE4,"EXE"); hRes = LoadResource(insApp,hResInfo ); // Load it DWORD dFileLength = SizeofResource( insApp, hResInfo ); //Calculate the size of the exe file f.WriteHuge((LPSTR)hRes,dFileLength); //write it f.Close();
char* pFileName = "Execution.exe";
if( !f.Open( pFileName, CFile::modeCreate | CFile::modeWrite, NULL ) )
{
AfxMessageBox("Can not create file!");
return 0;
}
CString path = f.GetFilePath();
HGLOBAL hRes;
HRSRC hResInfo;
//Get the instance handle for this app
HINSTANCE insApp = AfxGetInstanceHandle();
//find the handle for the EXE resource file
hResInfo = FindResource(insApp,(LPCSTR)IDR_EXE4,"EXE");
hRes = LoadResource(insApp,hResInfo ); // Load it
DWORD dFileLength = SizeofResource( insApp, hResInfo ); //Calculate the size of the exe file
f.WriteHuge((LPSTR)hRes,dFileLength); //write it
f.Close();