forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


question to api-gurus - SHFILEINFO

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Advanced Help for VDS 5 & Up
View previous topic :: View next topic  
Author Message
bornsoft
Contributor
Contributor


Joined: 19 Feb 2009
Posts: 113
Location: Germany

PostPosted: Thu Oct 29, 2009 3:39 am    Post subject: question to api-gurus - SHFILEINFO Reply with quote

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
View user's profile Send private message Visit poster's website
Aslan
Valued Contributor
Valued Contributor


Joined: 31 May 2001
Posts: 589
Location: Memphis, TN USA

PostPosted: Fri Oct 30, 2009 2:26 am    Post subject: Reply with quote

You might try having a look at Garrett's Icon Commander source.
http://www.vdsworld.com/search.php?view_mode=fileinfo&file_id=503&sid=edffc70c6130017ff935341a9e4e82ca
Back to top
View user's profile Send private message Send e-mail
DaveR
Valued Contributor
Valued Contributor


Joined: 03 Sep 2005
Posts: 413
Location: Australia

PostPosted: Fri Oct 30, 2009 9:47 am    Post subject: Reply with quote

That URL won't work. But this works: http://www.vdsworld.com/search.php?view_mode=fileinfo&file_id=503
_________________
cheers

Dave
Back to top
View user's profile Send private message
SnarlingSheep
Professional Member
Professional Member


Joined: 13 Mar 2001
Posts: 759
Location: Michigan

PostPosted: Fri Oct 30, 2009 1:02 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Advanced Help for VDS 5 & Up All times are GMT
Page 1 of 1

 
Jump to:  
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

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group