Help with getting an Icon from a file 
Author Message
 Help with getting an Icon from a file

I'm trying to get an icon from an existing file located at

C:\Program Files\OpenSA\Apache\Apache.exe

I compile the following code, and it gives no errors, but when I run the
application, it doesn't give me an icon at all...

 wc.hIcon = (HICON)LoadImage(NULL,"C:\\Program
Files\\OpenSA\\Apache\\Apache.exe",IMAGE_ICON,0,0,LR_LOADFROMFILE |
LR_DEFAULTSIZE);

Is this the right way to call the function?  I looked for examples, but
can't find any.  Any help would be appreciated.

Thanks!

--


Player Project Manager . theDial



Fri, 11 Oct 2002 03:00:00 GMT  
 Help with getting an Icon from a file
Fred,

Quote:
> I'm trying to get an icon from an existing file located at

> C:\Program Files\OpenSA\Apache\Apache.exe

> I compile the following code, and it gives no errors, but when I run the
> application, it doesn't give me an icon at all...

>  wc.hIcon = (HICON)LoadImage(NULL,"C:\\Program
> Files\\OpenSA\\Apache\\Apache.exe",IMAGE_ICON,0,0,LR_LOADFROMFILE |
> LR_DEFAULTSIZE);

> Is this the right way to call the function?

I dont think LoadImage() can load a resource from another app that way.
Its be much easier to just call SHGetFileInfo(), or even plain old
LoadLibraryEx() and LoadIcon(), provided you know the Icons resource ID in
the .exe

--
Tomas Restrepo
http://www.mvps.org/windev



Fri, 11 Oct 2002 03:00:00 GMT  
 Help with getting an Icon from a file
Hello,

  use ExtractIcon or ExtractIconEx function instead.

HTH,

--
ChainsaW



Sat, 12 Oct 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. getting icon from file extension

2. Getting file association icons...

3. Getting default icon for a file type

4. Getting the shell icon for any given file.

5. Getting Icons from Files and Directories

6. Getting the file's icon

7. Getting default icon for a file type

8. How to laod an icon from icon file?

9. Default Icon Hell: MFC Icon appears even after file and IDR_MAINFRAME changed

10. Urgent help: Getting files using HTTP protocol in C

11. Help, getting a character from a text file.

12. Help getting size of binary file for allocating pointer array

 

 
Powered by phpBB® Forum Software