Hi,
I want to read the RT_VERSION resource from an .exe file and change
the FILEVERSION and PRODUCTVERSION entires. But somehow it doesn't
work. I can load and copy the resource to memory, but when trying to
UpdateResource, the WinExplorer/Properties doesn't show any "Version"
Tab anymore. It seems to be destroyed.
Please, please help.
-Gernot
// Source code of my app:
int _tmain(int argc, _TCHAR* argv[])
{
HRSRC hResLoad;
HMODULE hExe;
hExe = LoadLibrary(argv[1]);
if (hExe == NULL) {printf("Could not load exe."); return 1;}
struct GF_FILE_INFO // File Version resource
{
BYTE header[40];
VS_FIXEDFILEINFO info;
};
GF_FILE_INFO *verinfo, v2;
HRSRC res;
HGLOBAL hres;
res = FindResource(hExe, MAKEINTRESOURCE(VS_VERSION_INFO),
RT_VERSION);
hres = LoadResource(hExe, res);
verinfo = (GF_FILE_INFO *)((char *)LockResource(hres));
// Duplicate version info - looks good in debugger
memcpy(&v2, verinfo, sizeof(GF_FILE_INFO));
FreeLibrary(hExe);
HANDLE handle = BeginUpdateResource(argv[1], FALSE);
if (!handle) {printf("Can't load: %s\n", argv[1]); return 1;}
if (!UpdateResource(handle, RT_VERSION,
MAKEINTRESOURCE(VS_VERSION_INFO),
LANG_NEUTRAL, &v2, sizeof(GF_FILE_INFO)))
printf ("Failed to UpdateResource\n");
if (!EndUpdateResource(handle, false)) printf("Failed to
EndUpdate\n");
return 0;
}
Post here, don't email. If you feel you have to mail, revert my
forename from:
tonreG.Frisch.at.Dream-D-Sign.de@invalid.com
________________________________________
Looking for a good game? Do it yourself!
GLBasic - you can do
www.GLBasic.com