fix bug at extracting file icon
This commit is contained in:
@@ -11,18 +11,11 @@ Namespace Internals
|
|||||||
''' </summary>
|
''' </summary>
|
||||||
''' <param name="FilePath">Hier übergeben Sie den Pfad der Datei von dem das Icon extrahiert werden soll.</param>
|
''' <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>
|
''' <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
|
Public Shared Function ExtractIcon(FilePath As String, Small As Boolean) As Icon
|
||||||
Dim hImgSmall As IntPtr
|
Dim icon As Icon
|
||||||
Dim hImgLarge As IntPtr
|
|
||||||
Dim shinfo As New SHFILEINFO
|
Dim shinfo As New SHFILEINFO
|
||||||
|
|
||||||
If Small Then
|
LibShell32.SHGetFileInfo(FilePath, 0, shinfo, Math.Truncate(Marshal.SizeOf(shinfo)), SHFILEINFO.SHGFI_ICON Or If(Small, SHFILEINFO.SHGFI_SMALLICON, SHFILEINFO.SHGFI_LARGEICON))
|
||||||
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
|
|
||||||
|
|
||||||
Try
|
Try
|
||||||
icon = Icon.FromHandle(shinfo.hIcon)
|
icon = Icon.FromHandle(shinfo.hIcon)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
Public Class LibShell32
|
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
|
End Class
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
Namespace Native
|
Namespace Native
|
||||||
|
|
||||||
|
|
||||||
<StructLayout(LayoutKind.Sequential)>
|
<StructLayout(LayoutKind.Sequential)>
|
||||||
Public Structure SHFILEINFO
|
Public Structure SHFILEINFO
|
||||||
|
|
||||||
Public Const SHGFI_ICON As UInteger = &H100
|
Public Const SHGFI_ICON As UInteger = &H100
|
||||||
Public Const SHGFI_LARGEICON As UInteger = &H0
|
Public Const SHGFI_LARGEICON As UInteger = &H0
|
||||||
Public Const SHGFI_SMALLICON As UInteger = &H1
|
Public Const SHGFI_SMALLICON As UInteger = &H1
|
||||||
@@ -16,7 +16,6 @@ Namespace Native
|
|||||||
Public szDisplayName As String
|
Public szDisplayName As String
|
||||||
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=80)>
|
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=80)>
|
||||||
Public szTypeName As String
|
Public szTypeName As String
|
||||||
|
|
||||||
End Structure
|
End Structure
|
||||||
|
|
||||||
End Namespace
|
End Namespace
|
||||||
|
|||||||
Reference in New Issue
Block a user