vc6怎么把打包在exe里的资源文件在运行时释放出来用什么函数
1个回答
展开全部
先看下资源文件的大小,放入dwSize中
HRSRC hmyrs = NULL;
HGLOBAL hrpt = NULL;
HANDLE hFile=NULL;
DWORD dwSize;
LPVOID lpBuffer;
dwSize = 2143794;
hmyrs = FindResource(AfxGetInstanceHandle(), MAKEINTRESOURCE(130), _T("EXE"));
if (hmyrs == NULL)
{
MessageBox(_T("error"), _T("wlf"), 0);
return;
}
hrpt = LoadResource(NULL, hmyrs);
if (hrpt == NULL)
{
MessageBox(_T("LoadResource error"));
}
lpBuffer = LockResource(hrpt);
DWORD wr;
hFile = ::CreateFile(_T("wlf.exe"), GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE)
{
MessageBox(_T("Create File error"));
}
if (false == WriteFile(hFile, lpBuffer, dwSize, &wr, NULL))
{
MessageBox(_T("Write File error"));
}
CloseHandle(hFile);
HRSRC hmyrs = NULL;
HGLOBAL hrpt = NULL;
HANDLE hFile=NULL;
DWORD dwSize;
LPVOID lpBuffer;
dwSize = 2143794;
hmyrs = FindResource(AfxGetInstanceHandle(), MAKEINTRESOURCE(130), _T("EXE"));
if (hmyrs == NULL)
{
MessageBox(_T("error"), _T("wlf"), 0);
return;
}
hrpt = LoadResource(NULL, hmyrs);
if (hrpt == NULL)
{
MessageBox(_T("LoadResource error"));
}
lpBuffer = LockResource(hrpt);
DWORD wr;
hFile = ::CreateFile(_T("wlf.exe"), GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE)
{
MessageBox(_T("Create File error"));
}
if (false == WriteFile(hFile, lpBuffer, dwSize, &wr, NULL))
{
MessageBox(_T("Write File error"));
}
CloseHandle(hFile);
追问
哦
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询