Hello,
How can my program find the icon associated with a specific mime-type?
TIA
[SOLVED] Extracting icon of associated program
-
- Posts: 11
- Joined: Thursday 1st October 2020 10:11am
[SOLVED] Extracting icon of associated program
Last edited by ForeverNoob on Sunday 15th September 2024 3:20pm, edited 1 time in total.
- BruceSteers
- Posts: 1825
- Joined: Thursday 23rd July 2020 5:20pm
- Location: Isle of Wight
- Contact:
Re: Extracting icon of associated program
Look at gb.desktop and DesktopMime.class https://gambaswiki.org/wiki/comp/gb.desktop/desktopmime
This will get the image from either a file name or from a mime type.
So you could use either...
hImage = GetMimeIcon("/path/to/the/file.html")
or
hImage = GetMimeIcon("text/html")
Or try Desktop.GetFileIcon https://gambaswiki.org/wiki/comp/gb.des ... etfileicon
component gb.desktop must be added to project in project properties
This will get the image from either a file name or from a mime type.
So you could use either...
hImage = GetMimeIcon("/path/to/the/file.html")
or
hImage = GetMimeIcon("text/html")
Public Sub GetMimeIcon(TypeOrFile As String, Optional Size As Integer = 32) As Image
Dim hMime As DesktopMime
If Exists(TypeOrFile) Then ' if it's a file then get it's mimetype
hMime = DesktopMime.FromFile(TypeOrFile)
Else
hMime = = DesktopMime[TypeOrFile]
Endif
If not hMime Then Error.Raise("mime type not found for " & TypeOrFile)
Dim hImage as Image = hMime.GetIcon(Size)
Return hImage
End
Or try Desktop.GetFileIcon https://gambaswiki.org/wiki/comp/gb.des ... etfileicon
Dim hPic As Picture = Desktop.GetFileIcon(Path, iSize, True)
component gb.desktop must be added to project in project properties
If at first you don't succeed , try doing something differently.
BruceS
BruceS
-
- Posts: 11
- Joined: Thursday 1st October 2020 10:11am
Re: Extracting icon of associated program
That works fine. Thanks.BruceSteers wrote: ↑Sunday 15th September 2024 12:52pm
Dim hPic As Picture = Desktop.GetFileIcon(Path, iSize, True)
component gb.desktop must be added to project in project properties
- BruceSteers
- Posts: 1825
- Joined: Thursday 23rd July 2020 5:20pm
- Location: Isle of Wight
- Contact:
Re: [SOLVED] Extracting icon of associated program
you're welcome
If at first you don't succeed , try doing something differently.
BruceS
BruceS