Extract stored executables and files in resource
Extracts executables or other files stored as binary data in the resource of your executable
AI
Tóm tắt bởi AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
Mã nguồn
BOOL WriteFileFromResource(int resourceid, LPCTSTR resourcetype, char* filename, bool createdirectory, char* directory)
{
if (createdirectory)
{
HRESULT result;
result = CreateDirectory(directory, NULL);
if (result == 0)
{
return FALSE;
}
result = SetCurrentDirectory(directory);
if (result == 0)
{
return FALSE;
}
}
HRSRC hRsrc;
hRsrc = FindResource(NULL, MAKEINTRESOURCE(resourceid), resourcetype);
if (hRsrc == NULL)
{
return FALSE;
}
HGLOBAL filedata;
filedata = LoadResource(NULL, hRsrc);
if (filedata == NULL)
{
return FALSE;
}
DWORD size;
size = SizeofResource(NULL, hRsrc);
if (size < 0)
{
return FALSE;
}
FILE* file;
file = fopen(filename, "wb");
if (file == NULL)
{
return FALSE;
}
fwrite(filedata, size, 1, file);
fclose(file);
return TRUE;
}
Bình luận gốc (3)
Được khôi phục từ Wayback Machine