PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → Icon exctraction from executable
Icon exctraction from executable
Débuté par Vassilis, 28 nov. 2011 15:04 - 3 réponses
Posté le 28 novembre 2011 - 15:04
Is in WD some way to extract the executable's icon, in order to assign this value to an image control ?.
The exeinfo() function does not provide such info I need.
Thank you in advance.
Posté le 28 novembre 2011 - 15:44
Vassilis,
first you must include the icons in your project, under the "Other" section.
Then you can just use these icons, by referring the filename, without a path.
As if these files are on disk, in your exectables map.
i.e. ImageControl1 = "Vassilis.jpg"
Posté le 28 novembre 2011 - 16:45
Hi Vassilis,
Here is a code snippet to extract the icon of another executable file. (The code to extract the icon of an ordinary file is different and a little bit more complex.)
In this example IMG_Icon is an image control with a size of 32x32. (I assume in WD17 we will be able to use the brand new image variable.)
IF fFileExist(sExe) THEN
hDC is int = dStartDrawing(IMG_Icon,dErase) // Get Device Context
dFill(0,0,White) // White-clear the image control

// Since it's an EXE we do not use SHGetFileInfo but ExtractIconA
hIcon is int = API("Shell32", "ExtractIconA", SysInstance(), sExe+Charact(0), 0)
IF hIcon THEN
API("user32", "DrawIcon", hDC, 0, 0, hIcon)
API("user32", "DestroyIcon", hIcon)
END
END

Then you can use the content of IMG_Icon to copy in any other image control. In my code I'm using dSaveImageBMP(IMG_Icon,inMemory) inside a LooperAddLine() instruction to get the icon in my looper (using an attribute on an image control).
Hope this helps.
Best regards,
Alexandre Leclerc
Posté le 29 novembre 2011 - 15:41
Thank you Alexandre. This code is what I want !!!