如何把这段代码的资源加载变成路径加载,求大神指点
void CBuildDialog::CompressUpx(CString inpath){
HRSRC hResInfo;
HGLOBAL hResData;
DWORD dwSize,dwWritten;
LPBYTE p;
HANDLE hFile;
// 查找所需的资源
hResInfo = FindResource(NULL,MAKEINTRESOURCE(IDR_UPX),"EXE");
if(hResInfo == NULL) return;
// 获得资源尺寸
dwSize = SizeofResource(NULL,hResInfo);
// 装载资源
hResData = LoadResource(NULL,hResInfo);
if(hResData == NULL) return;
// 为数据分配空间
p = (LPBYTE)GlobalAlloc(GPTR, dwSize);
if (p == NULL) return;
// 复制资源数据
CopyMemory((LPVOID)p, (LPCVOID)LockResource(hResData), dwSize);
char Path;
GetCurrentDirectory(256, Path);
strcat(Path,"upx.exe");
DeleteFile(Path);
hFile = CreateFile(Path,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,0,NULL);
if(hFile == NULL) return;
WriteFile(hFile,(LPVOID)p,dwSize,&dwWritten,NULL);
CloseHandle(hFile);
ShellExecute(this->m_hWnd,"open",Path, inpath,"",SW_HIDE);
BOOL del;
do
{
del = DeleteFile(Path);
} while(!del);
} ShellExecute(NULL,"open",Path, inpath,"",SW_HIDE); //Path upx的路径,inpath 被压缩文件路径 一句话搞定 然后删除 upx如果有需要的话
do
{
del = DeleteFile(Path);
} while(!del);
}
页:
[1]