Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting the associated icon of a file type
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00385694
Message ID:
00385725
Views:
13
>Hi all,
>I need to create a list of files and I want to show the associated icon. I think I need to access to Windows Registry but I don't know how to get the icon. Also, how can I extract an icon of an EXE or DLL, because some icon association are from executable files.
>
>Can anybody help me ???
>(Sorry by my poor english)
>
>Thank in advance!

I don't think that putting the icon in a list is possible. You can extract the icon by its file association like so...
DECLARE SHORT DrawIcon IN Win32API;
  INTEGER Hdc, INTEGER X, INTEGER Y, INTEGER hIcon
DECLARE INTEGER ExtractAssociatedIcon IN Shell32;
 INTEGER hInst, STRING @lpIconPath, INTEGER @lpiIcon
DECLARE INTEGER GetClassLong IN Win32API;
  INTEGER hWnd, INTEGER nIndex 
DECLARE INTEGER GetDC IN Win32API;
  INTEGER hWnd 
DECLARE INTEGER ReleaseDC IN Win32API;
  INTEGER hwnd, INTEGER hdc 

PROCEDURE DisplayIcon

  LPARAMETER pcfilename

  LOCAL lnHdc, lnHWnd, lnHIcon, lnHInstance, lniconindex
  lniconindex = 0
  * Foxtools required here
  lnHWnd = _WHToHwnd(_WFindTitl(ThisForm.Caption))
  lnHdc = GetDC(lnHWnd)
  lnHinstance = GetClassLong(lnHWnd, GCL_HMODULE) && GCL_HMODULE = -16
  HIcon = ExtractAssociatedIcon(lnHinstance, @pcfilename, @lniconindex)
  UDraw = DrawIcon(lnHdc, 0, 0, lnHIcon)
  = ReleaseDC(lnHWnd, lnHdc) 
  RETURN
ENDPROC
Note, however, that it's not very stable. You'll need a timer to monitor the window status. Further, it's limited to displaying 32x32 icons.
George

Ubi caritas et amor, deus ibi est
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform