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)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
Public Class LibShell32
|
||||
|
||||
Public Declare Auto Function SHGetFileInfo Lib "shell32.dll" (ByVal pszPath As String, ByVal dwFileAttributes As UInteger, ByRef psfi As SHFILEINFO, ByVal cbSizeFileInfo As UInteger, ByVal uFlags As UInteger) As IntPtr
|
||||
Public Declare Function SHGetFileInfo Lib "shell32.dll" (ByVal pszPath As String, ByVal dwFileAttributes As UInteger, ByRef psfi As SHFILEINFO, ByVal cbSizeFileInfo As UInteger, ByVal uFlags As UInteger) As IntPtr
|
||||
|
||||
End Class
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
Namespace Native
|
||||
|
||||
|
||||
<StructLayout(LayoutKind.Sequential)>
|
||||
Public Structure SHFILEINFO
|
||||
|
||||
Public Const SHGFI_ICON As UInteger = &H100
|
||||
Public Const SHGFI_LARGEICON As UInteger = &H0
|
||||
Public Const SHGFI_SMALLICON As UInteger = &H1
|
||||
@@ -16,7 +16,6 @@ Namespace Native
|
||||
Public szDisplayName As String
|
||||
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=80)>
|
||||
Public szTypeName As String
|
||||
|
||||
End Structure
|
||||
|
||||
End Namespace
|
||||
|
||||
Reference in New Issue
Block a user