Mapped.IconExtractor

This commit is contained in:
2023-01-02 14:35:59 +01:00
parent 8dbd0a764e
commit 3c49701873
7 changed files with 359 additions and 4 deletions

View File

@@ -1,5 +1,7 @@
Imports System.Drawing
Imports System.Runtime.InteropServices
Imports Pilz.Win32.Mapped
Imports Pilz.Win32.Native
Namespace Internals
@@ -10,10 +12,11 @@ Namespace Internals
''' Extrahiert das Icon aus einer Datei oder aus einem Ordner.
''' </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(FilePath As String, Small As Boolean) As Icon
''' <param name="size">Bei übergabe von true wird ein kleines und bei false ein großes Icon zurück gegeben.</param>
Public Shared Function ExtractIcon(FilePath As String, size As SystemIconSize) As Icon
Dim icon As Icon
Dim shinfo As New SHFILEINFO
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))