return an ICON

This commit is contained in:
2023-01-02 15:06:54 +01:00
parent 1b0b0e22c2
commit 4393c59ab7
4 changed files with 3 additions and 14 deletions

View File

@@ -18,7 +18,7 @@ Namespace Internals
Dim shinfo As New SHFILEINFO Dim shinfo As New SHFILEINFO
Dim small As Boolean = size = SystemIconSize.Small Dim small As Boolean = size = SystemIconSize.Small
LibShell32.SHGetFileInfo(FilePath, 0, shinfo, Math.Truncate(Marshal.SizeOf(shinfo)), SHFILEINFO.SHGFI_ICON Or If(Small, SHFILEINFO.SHGFI_SMALLICON, SHFILEINFO.SHGFI_LARGEICON)) Shell32.SHGetFileInfo(FilePath, 0, shinfo, Math.Truncate(Marshal.SizeOf(shinfo)), SHFILEINFO.SHGFI_ICON Or If(small, SHFILEINFO.SHGFI_SMALLICON, SHFILEINFO.SHGFI_LARGEICON))
Try Try
icon = Icon.FromHandle(shinfo.hIcon) icon = Icon.FromHandle(shinfo.hIcon)

View File

@@ -8,7 +8,7 @@ Namespace Mapped
Return Internals.IconExtractor.ExtractIcon(filePath, size) Return Internals.IconExtractor.ExtractIcon(filePath, size)
End Function End Function
Public Function ExtractIconFromFileExtension(fileExtension As String, size As SystemIconSize) Public Function ExtractIconFromFileExtension(fileExtension As String, size As SystemIconSize) As Icon
Return Internals.IconFactory.IconFromExtensionShell(fileExtension, size) Return Internals.IconFactory.IconFromExtensionShell(fileExtension, size)
End Function End Function

View File

@@ -1,9 +0,0 @@
Namespace Native
Public Class LibShell32
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 Namespace

View File

@@ -61,9 +61,7 @@ Namespace Native
Public Shared Function ExtractIconEx(<MarshalAs(UnmanagedType.LPTStr)> ByVal lpszFile As String, ByVal nIconIndex As Integer, ByVal phIconLarge As IntPtr(), ByVal phIconSmall As IntPtr(), ByVal nIcons As Integer) As Integer Public Shared Function ExtractIconEx(<MarshalAs(UnmanagedType.LPTStr)> ByVal lpszFile As String, ByVal nIconIndex As Integer, ByVal phIconLarge As IntPtr(), ByVal phIconSmall As IntPtr(), ByVal nIcons As Integer) As Integer
End Function End Function
<DllImport("Shell32", CharSet:=CharSet.Auto)> 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
Public Shared Function SHGetFileInfo(ByVal pszPath As String, ByVal dwFileAttributes As Integer, <Out> ByRef psfi As SHFILEINFO, ByVal cbFileInfo As Integer, ByVal uFlags As FileInfoFlags) As IntPtr
End Function
End Class End Class