Searching a code-snippet for getting a 48px file icon in VB6

The place for programming-related topics.
Post Reply
Anton
Cadet
Posts: 2
Joined: 15 Mar 2010, 15:22

Searching a code-snippet for getting a 48px file icon in VB6

Post by Anton »

Hello Timo.

During my exhausting web-searches I saw, that you are a really expert in VB6 and api's.
I currently use "SHGetFileInfo" and "ImageList_Draw" to retrieve the 16px and 32px icons from file (by it's file-extension).

Now I want to determine the 48px icons, but as I saw this is not possible in my old-fashioned way.
I got the infos, that I would have to use "SHGetImageList" and "ImageList_GetIcon", but I'm unfortunately not able to put the things together.

So my last try is to beg you for such a snippet.
I think for you it's quite easy.

Would you be so kind and help me?

Regarts,
Anton
User avatar
TiKu
Administrator
Administrator
Posts: 832
Joined: 28 Sep 2004, 21:10
Location: München
Contact:

Re: Searching a code-snippet for getting a 48px file icon in VB6

Post by TiKu »

You should avoid extracting the icon, because it'll lose quality if you do so. Try to use the system image list directly or draw the icon directly, using ImageList_DrawEx or similar.

Here's the code for SHGetImageList:

Code: Select all

Private IID_IImageList As UUID
Private Declare Function CLSIDFromString Lib "ole32.dll" (ByVal pString As Long, CLSID As UUID) As Long
Private Declare Function SHGetImageListAsLong Lib "shell32.dll" Alias "#727" (ByVal flags As Long, IID As UUID, ByVal pIImageList As Long) As Long
Const strIID_IImageList = "{46EB5926-582E-4017-9FDF-E8998DAA0950}"
Const SHIL_LARGE = 0
Const SHIL_SMALL = 1
Const SHIL_EXTRALARGE = 2
Const SHIL_SYSSMALL = 3
Const SHIL_JUMBO = 4
Dim hImgLst As Long

CLSIDFromString StrPtr(strIID_IImageList), IID_IImageList
SHGetImageListAsLong SHIL_EXTRALARGE, IID_IImageList, VarPtr(hImgLst)
Now hImgLst contains the handle of the 48x48 system image list.
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
Anton
Cadet
Posts: 2
Joined: 15 Mar 2010, 15:22

Re: Searching a code-snippet for getting a 48px file icon in VB6

Post by Anton »

After finding out, that your "UUID" has to be defined as

Code: Select all

Public Type UUID
    Data1 As Long
    Data2 As Integer
    Data3 As Integer
    Data4(7) As Byte
End Type
and some thoughts about how your solution could fit into my old one, I came to the conclusion to reuse the prior determind "tSHFILEINFO.iIcon".
So I just had to use the imagelist-id I got from your APIs with my old code and finally...


...IT WORKS LIKE A CHARM!

Realy MANY thanks to you Timo!

BTW: Ich komme auch aus Deutschland, aber ich denke Englisch ist hier die erwünschte Sprache, oder? ;-)
User avatar
TiKu
Administrator
Administrator
Posts: 832
Joined: 28 Sep 2004, 21:10
Location: München
Contact:

Re: Searching a code-snippet for getting a 48px file icon in VB6

Post by TiKu »

Anton wrote:Realy MANY thanks to you Timo!
You're welcome.
Anton wrote:BTW: Ich komme auch aus Deutschland, aber ich denke Englisch ist hier die erwünschte Sprache, oder? ;-)
Ja, englisch ist mir lieber, denn so haben mehr Leute etwas von den Informationen.
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
Post Reply