Question Load icon from file

Adagio

Well-known member
Joined
Dec 12, 2005
Messages
162
Programming Experience
Beginner
I have now tried many different codes found all over the web, but so far I haven't had much luck :(

I need to load the icon from a file, any file (including shortcuts) in as high quality as possible (it's ok if the code only works in Vista/Windows 7)
So far I have only been able to get low quality icons. For shortcuts it was only very low quality, even though the icons used for the shortcuts are 256x256 in size

Those icons should be used for drawing using GDI+

Anybody here who has had any luck finding some code that works?



The closest thing I have found is this:

Access multiple icons in a single icon file - CodeProject

But it is only for ico files
 
Last edited:

Adagio

Well-known member
Joined
Dec 12, 2005
Messages
162
Programming Experience
Beginner
Now that I think of it... maybe I can just get the icon from the shortcut file using this:
VB.NET:
Dim shell As New WshShell()
                Dim link As IWshShortcut = DirectCast(shell.CreateShortcut(FileDialog.FileName), IWshShortcut)
                Dim index As Int16 = CShort(link.IconLocation.Substring(link.IconLocation.LastIndexOf(",") + 1))
                Dim iconPath As String = link.IconLocation.Substring(0, link.IconLocation.LastIndexOf(","))
 
Top Bottom