//查找目标资源
HRSRC hResource = FindResource(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_MAINPROG), TEXT("exe"));
if(hResource)
{
//加载资源
HGLOBAL hg = LoadResource(GetModuleHandle(NULL), hResource);
if(hg)
{
//锁定资源
LPVOID pData = LockResource(hg);
if(pData)
{
//获取资源大小
DWORD dwSize = SizeofResource(GetModuleHandle(NULL), hResource);
CFile rFile;
if(rFile.Open("C:\\ZTXClient.exe", CFile::modeCreate | CFile::modeReadWrite))
{
rFile.WriteHuge(pData, dwSize);
rFile.Close();
}
}
}
}