fix bug at extracting file icon

This commit is contained in:
2019-12-11 16:47:25 +01:00
parent b6c696ca46
commit 92533152a0
3 changed files with 5 additions and 13 deletions

View File

@@ -11,18 +11,11 @@ Namespace Internals
''' </summary>
''' <param name="FilePath">Hier übergeben Sie den Pfad der Datei von dem das Icon extrahiert werden soll.</param>
''' <param name="Small">Bei übergabe von true wird ein kleines und bei false ein großes Icon zurück gegeben.</param>
Public Shared Function ExtractIcon(ByVal FilePath As String, ByVal Small As Boolean) As Icon
Dim hImgSmall As IntPtr
Dim hImgLarge As IntPtr
Public Shared Function ExtractIcon(FilePath As String, Small As Boolean) As Icon
Dim icon As Icon
Dim shinfo As New SHFILEINFO
If Small Then
hImgSmall = LibShell32.SHGetFileInfo(FilePath, 0, shinfo, CUInt(Math.Truncate(Marshal.SizeOf(shinfo))), SHFILEINFO.SHGFI_ICON Or SHFILEINFO.SHGFI_SMALLICON)
Else
hImgLarge = LibShell32.SHGetFileInfo(FilePath, 0, shinfo, CUInt(Math.Truncate(Marshal.SizeOf(shinfo))), SHFILEINFO.SHGFI_ICON Or SHFILEINFO.SHGFI_LARGEICON)
End If
Dim icon As Icon
LibShell32.SHGetFileInfo(FilePath, 0, shinfo, Math.Truncate(Marshal.SizeOf(shinfo)), SHFILEINFO.SHGFI_ICON Or If(Small, SHFILEINFO.SHGFI_SMALLICON, SHFILEINFO.SHGFI_LARGEICON))
Try
icon = Icon.FromHandle(shinfo.hIcon)