View previous topic :: View next topic |
Author |
Message |
bornsoft Contributor
Joined: 19 Feb 2009 Posts: 113 Location: Germany
|
Posted: Thu Oct 29, 2009 3:39 am Post subject: question to api-gurus - SHFILEINFO |
|
|
hello,
i need to list associated icons to files in a bitlist. i tried the registry-way, but this not always works.
on my research i stumbled over SHFILEINFO in shell32.dll which ist used by the explorer to show associated icons.
i found the following code in VisualBasic and wonder if it's possible to make this work in vds.
i've no idea how to start and - if i'm not wrong - this will return just a handle to the icon, so what next?
Code: |
Private Const SHGFI_ATTRIBUTES As Long = &H800
Private Const SHGFI_DISPLAYNAME As Long = &H200
Private Const SHGFI_EXETYPE As Long = &H2000
Private Const SHGFI_ICON As Long = &H100
Private Const SHGFI_ICONLOCATION As Long = &H1000
Private Const SHGFI_LARGEICON As Long = &H0
Private Const SHGFI_LINKOVERLAY As Long = 32768 '= &H8000
Private Const SHGFI_OPENICON As Long = &H2
Private Const SHGFI_PIDL As Long = &H8
Private Const SHGFI_SELECTED As Long = &H10000
Private Const SHGFI_SHELLICONSIZE As Long = &H4
Private Const SHGFI_SMALLICON As Long = &H1
Private Const SHGFI_SYSICONINDEX As Long = &H4000
Private Const SHGFI_TYPENAME As Long = &H400
Private Const SHGFI_USEFILEATTRIBUTES As Long = &H10
Private Const MAX_PATH = 260
Private Type SHFILEINFO
hicon As Long
iIcon As Long
dwAttributes As Long
szDisplayName As String * MAX_PATH
szTypeName As String * 80
End Type
Private Declare Function SHGetFileInfo Lib "shell32.dll" _
Alias "SHGetFileInfoA" (ByVal pszPath As String, _
ByVal dwFileAttributes As Long, psfi As SHFILEINFO, _
ByVal cbFileInfo As Long, ByVal uFlags As Long) As Long
...
Public Function GetDisplayedIcon( _
ByRef strFilename As String, _
Optional ByVal lngFlags As shgfiFlags = shgfiLarge) _
As StdPicture
Dim fi As SHFILEINFO
Dim lngReturn As Long
lngFlags = lngFlags Or SHGFI_ICON
lngReturn = SHGetFileInfo(strFilename, 0, fi, Len(fi), lngFlags)
If lngReturn = 0 Then
Err.Raise 5
End If
Set GetDisplayedIcon = _
PictureFromHandle(fi.hicon, vbPicTypeIcon, True)
End Function
|
the whole text i found is here: http://www.aboutvb.de/khw/artikel/khwassocicon.htm
(it's in german, but something similar in english should be found easily)
greetings
marcus |
|
Back to top |
|
|
Aslan Valued Contributor
Joined: 31 May 2001 Posts: 589 Location: Memphis, TN USA
|
|
Back to top |
|
|
DaveR Valued Contributor
Joined: 03 Sep 2005 Posts: 413 Location: Australia
|
|
Back to top |
|
|
SnarlingSheep Professional Member
Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Fri Oct 30, 2009 1:02 pm Post subject: |
|
|
You can get the handle to a files associated icon fairly easily, but you are correct, what next?
Code: | %p = C:\boot.ini
%a = 0
%%hInst = @lib(kernel32,GetModuleHandleA,INT:,NIL:)
%%ret = @lib(shell32,ExtractAssociatedIconA,INT:,%%hInst,INT:@addr("%p"),INT:@addr("%a"))
info Icon Handle: %%ret
exit |
_________________ -Sheep
My pockets hurt... |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|