Link to home
Start Free TrialLog in
Avatar of hess
hess

asked on

Getting the icon of a file

How can i get the icon of a file, say netscape.exe, and set it as the picture for a command button.
Avatar of hess
hess

ASKER

Edited text of question
You can use some Icon editing programs to browse these files.   You might want to try MicroAngelo... It is shareware.
Avatar of hess

ASKER

From code... I ned to say command1.picture=???
no no no.. you cant do that...
If you Already have an .ICO file on your drive somewhere..

then yes..  Command1.picture  = TheIcon.ico

You have to also set the Style to 1-Graphical

Tey it with the Icons in the Graphics\Icons\...directories..
also.. what you CAN do easily.. to get the icon..
is to open WindowsExplorer in LARGE Icons mode..
and find the EXE file.. take a screen shot..
then cut and paste the item in PAINT.. and make a small bmp file.. it wont b and ICO file.. but will be fine for a Command Button.  While in Paint.. give it a Gra Fill to the background.. to match the Comand Button..
colors are RGB(192,192,192)
Avatar of hess

ASKER

i need to do this all in code... no work arounds.  i need to get the icon of say netscape.exe all from code. I want to ony have the path of the file and some how return it's icon then put it on a command button
hess,

Here is an address where you can find a project which does what you want:
http://www.geocities.com/SiliconValley/Park/8079/vbsolutions.html

then select the project Extract.

I am not the author (his name is Simon Carter) and the whole credit should go to him.

Steve.
ASKER CERTIFIED SOLUTION
Avatar of Grdv
Grdv

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You could use GetAssociatedIcon() which is an API call..... ;->
Avatar of hess

ASKER

thank. i figured it out on my own but your answer looks like it'll work so i'll award you the points
Whose answer??? I guess Grdv . o O ;->

//Vik
hmm... well after all I was first, but you method is less complexed viktornet...
mine comes from a routine to get the complete file information....

// Grdv
I just wonder why need info from file, just extract the icon and that's all ;->

Talk to ya 2 L8R Bye
Avatar of hess

ASKER

a made a tollbar similar to the one that comes with office... i need to to get the icon of a file while only having the relivant path
viktornet: I've included a fileinfo dialogbox in my last SDI program...