Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ExtractIcon or ExtractAssociatedIcon...
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00653833
Message ID:
01044928
Views:
19
>>>What is the proper function to retrieve an icon from an executable or DLL so I can load it into a ImageList with .ADD(,"Drive",LOADPICTURE("Drive.ico"))
>>
>>Actually, neither of these will do what you want. Both return a handle to the icon. The handle can be then used by an API function such as DrawIcon(). Unfortunately, the handle does not produce a physical file and there isn't an API call that can do this directly.
>
>Not quite. It can be done directly in VFP7:
>
>#define PICTYPE_ICON 3
>#define IID_IDispatch Chr(0x00)+Chr(0x04)+Chr(0x02)+Chr(0x00)+ ;
>		Replicate(Chr(0x00), 4)+Chr(0xC0)+Replicate(Chr(0x00), 6)+Chr(0x46)
>
>* Large icons
>Declare long ExtractIconEx in shell32 String @ File, long iconIndex, ;
>	long @ iconLarge, long iconSmall, long nIcons
>* Small icons
>*Declare long ExtractIconEx in shell32 String @ File, long iconIndex, ;
>*	long iconLarge, long @ iconSmall, long nIcons
>
>Declare Long OleCreatePictureIndirect In oleaut32 ;
>	String @ PicDesc, String @ RefIID, Long fPictureOwnsHandle, Object @ IPic
>
>IconFile = "D:\Program Files\Microsoft Visual Studio\VFP98\VFP6.exe"
>IconIndex = 6
>hIcon = 0
>
>* Large icon
>ExtractIconEx(@IconFile, IconIndex, @hIcon, 0, 1)
>* SmallIcon
>*ExtractIconEx(@IconFile, IconIndex, 0, @hIcon, 1)
>
>* Create Picture object according to PICTDESC structure
>PictDesc = DWord(16) ;				&& Size of PICTDESC structure
>		 + DWord(PICTYPE_ICON) ;	&& Type of picture
>		 + DWord(hIcon) ;		&& HICON
>		 + DWord(0)			&& HPALETTE
>IPic = 0
>iid = IID_IDispatch
>OleCreatePictureIndirect(@PictDesc, @iid, 1, @IPic)
>
>ImageList.ListImages.ADD(,"SomePict",IPic)
>
Does it mean I have to use ImageList for "GetFile" functionality?

Thanks.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform