Gelezen documentatie:
http://msdn.microsoft.com..._win32_Updating_Resources
Wat doe ik hier fout?
Het probleem zit in het gedeelte van UpdateResource?
Om precies te zijn zit het probleem in de functie UpdateResource.
Ik wil in een exe-bestand het icoontje veranderen adhv dit programma.
Hij laadt momenteel het bestandje van explorer.exe (en laat deze zien)
Alles gaat goed totdat het bestandje test2.exe aangepast wordt met het nieuwe icoon en dan krijg ik een foutmelding.
Het bestand test2.exe wordt ook gelijk onbruikbaar.
(Ik gebruik Visual C++ 2003)
http://msdn.microsoft.com..._win32_Updating_Resources
C++:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
| HMODULE hExe; // handle to existing .EXE file HRSRC hResLoad; HANDLE hUpdateRes; // update resource handle void *lpResLock; // pointer to resource data char iconfile[] = "c:\\explorer.exe"; char exefile[] = "test2.exe"; hExe = LoadLibrary(iconfile); if (hExe == NULL) MessageBox("Could not load exe."); hResLoad = (HRSRC) ExtractIcon(NULL,iconfile,0); if( hResLoad == NULL ) MessageBox("Errortje!"); icn_icon.SetIcon((HICON)hResLoad); lpResLock = LockResource(hResLoad); if (lpResLock == NULL) MessageBox("Could not lock dialog box."); //HIER BEGINT HET PROBLEEM, TRUE GEEFT AAN DAT DE RESOURCE //OVERSCHREVEN MOET WORDEN hUpdateRes = BeginUpdateResource(exefile,TRUE); if( hUpdateRes == NULL ) MessageBox("Could not begin Update"); //BIJ DEZE FUNCTIE GAAT HET FOUT UpdateResource(hUpdateRes, RT_ICON, MAKEINTRESOURCE(0), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), hResLoad, // ptr to resource info SizeofResource(hExe,hResLoad) ); // size of resource info. //HIER WORDEN DE WIJZINGEN DOORGEVOERD DISCARD=FALSE if (!EndUpdateResource(hUpdateRes, FALSE)) MessageBox("Could not write changes to file."); DestroyIcon((HICON)hResLoad); // Clean up. if (!FreeLibrary(hExe)) MessageBox("Could not free executable."); |
Wat doe ik hier fout?
Het probleem zit in het gedeelte van UpdateResource?
Om precies te zijn zit het probleem in de functie UpdateResource.
Ik wil in een exe-bestand het icoontje veranderen adhv dit programma.
Hij laadt momenteel het bestandje van explorer.exe (en laat deze zien)
Alles gaat goed totdat het bestandje test2.exe aangepast wordt met het nieuwe icoon en dan krijg ik een foutmelding.
Het bestand test2.exe wordt ook gelijk onbruikbaar.
(Ik gebruik Visual C++ 2003)
[ Voor 55% gewijzigd door cobratbq op 07-09-2003 20:41 ]
One ring to rule them all, one ring to find them, one ring to bring them all, and in darkness bind them...