Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
File association icons
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00728027
Message ID:
00728137
Views:
34
Frank,

Thankyou for your help. I have printed of the messages and looking through them.

>ExtractIconEx(@IconFile, IconIndex, @hIcon, 0, 1)

Will this work where the file is the actual document (e.g. myLetter.doc or numbers.xls) or does the icon file have to be the original/source application?

Urfan


>Urfan,
>
>This is not a beauty but it will get You running (for mor info see message #656045 where
>I basicly have the code from.
>
>Create a form with a Commandbutton and an imageList Control named ImageList.
>Additionally add a Method DWORD
>
>In the commandbutton put
>
>#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"
>iconFile = GetFile("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 = Thisform.DWord(16) ;				&& Size of PICTDESC structure
>		 + Thisform.DWord(PICTYPE_ICON) ;	&& Type of picture
>		 + Thisform.DWord(hIcon) ;		&& HICON
>		 + Thisform.DWord(0)			&& HPALETTE
>IPic = 0
>iid = IID_IDispatch
>OleCreatePictureIndirect(@PictDesc, @iid, 1, @IPic)
>
>Thisform.ImageList.ListImages.ADD(,"SomePict",IPic)
>
>
>and in the DWORD-Method
>
>	*PROCEDURE LongToStr
>	* This function converts a long to a string
>		PARAMETERS nLongVal
>		LOCAL nLoopVar, strReturn
>
>		strReturn 	= ""
>		FOR nLoopVar = 24 TO 0 STEP -8		&& Long ist vier bytes lang
>			strReturn = CHR(INT(nLongVal/(2^nLoopVar))) + strReturn
>			nLongVal 	= MOD(nLongVal, (2^nLoopVar))
>		NEXT
>	RETURN strReturn
>
>
>Save and run the form. Click on the button and select EXCEL.EXE for excample.
>
>
>? m.MyForm.imageList.listImages.count
>
>
>should now return 1.
>
>There are several messages about ExtractAssociatedIcon etc. (Also have a look
>at the WinAPI-Section). These all get You a handle to an Icon. For me the hardest
>thing was to actually get this into a "PICTURE" that can pe put in an ImageList
>witch this does. From here it should be quite simple to get the associated file
>for a given extension etc.
>
>Let me know if I can be of any more help
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform