Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Win32API UpdateResource() to change exe's Icon
Message
De
10/05/2003 00:02:04
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Win32API UpdateResource() to change exe's Icon
Divers
Thread ID:
00787006
Message ID:
00787006
Vues:
341
I'm stuck trying to figure out how to programatically change the icon in a .exe file. We use a single VB program (written in house) that "Launches" our various VFP applications for the users, we want to be able to change the icon in this "Launcher" program for each application automatically with a custom icon for that application. We could do it manually, but then when we make a change to the Launcher and copy it back out to each application directory on the LAN, we would need to do that manual process again.... You may be asking what this launcher program does... It does a few things that help us deploy VFP applications to the users' local machines. It's quite nifty. It makes sure the latest version of the application, VFP runtimes and support files on the user's local PC are the latest version. Then it runs the VFP application on the local PC.

Anyway, I'm stuck on the last win32api function UpdateResource, which is supposed to let me make the changes to the .exe file in order to change the icon in the .exe. I'm also stuck on the macro function: MAKEINTRESOURCE that seems to be required in order to specify "RT_ICON", which I've found is specified by MAKEINTRESOURCE(3). Is there a VFP equivallent to this, or is this not possible?

Thank you tremendously, in advance!!

The C format for UpdateResource is:

BOOL UpdateResource( HANDLE hUpdate,
LPCTSTR lpType,
LPCTSTR lpName,
WORD wLanguage,
LPVOID lpData,
DWORD cbData
);

The VFP program I'm writing is below. First it calls BeginUpdateResource to get a handle to the .exe file. Then it call LoadImage to load the new icon file into memory. Then it needs to do UpdateResource to update the icon in the resource file. Maybe I'm doing this all wrong... :( Any advise would be greatly appreciated.

* chgIcon.prg
DECLARE integer BeginUpdateResource;
IN Win32api;
string pFileName,;
integer bDeleteExistingResources

m.lnHandle= BeginUpdateResource("c:\temp\testicon\main.exe", 0)
? "main.exe handle:", m.lnHandle

DECLARE integer LoadImage;
IN Win32api;
integer hinst,;
string lpszName,;
integer uType,;
integer cxDesired,;
integer cyDesired,;
integer fuLoad

*The constants are:
*- IMAGE_ICON (value 1, use IMAGE_BITMAP, value 0, to load BMPs)
*- LR_DEFAULTSIZE ,value 0x0040 (VFP accept this notation for Hex values)
*- LR_LOADFROMFILE , value 0x0010

m.lnIconHandle= LoadImage(0, "c:\temp\testicon\newicon.ico", 1, 0x0040,0x0040,0x0010)
? "icon handle:", m.lnIconHandle

DECLARE integer UpdateResource;
IN Win32api;
integer hUpdate,;
string lpType,;
string lpName,;
integer wLanguage,;
integer lpData,;
integer cbData

? "update:", UpdateResource(m.lnHandle, MAKEINTRESOURCE(3), "", 0, m.lnIconHandle, 0)
&& argh! How do I do this last one?
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform