fix bug at extracting file icon
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user