Schönen guten Abend,
ich möchte das Icon eines Ordners in einer Picturebox anzeigen. Das funktioniert auch soweit mit diesem Code.
Nun zu meinem Problem. Wie kann ich jetzt noch zusätzliche Informationen abrufen. Z.b. in welcher Datei ist das Icon gespeichert und welchen Index hat es.
Hoffe auf eure Hilfe.
Grüße TM
ich möchte das Icon eines Ordners in einer Picturebox anzeigen. Das funktioniert auch soweit mit diesem Code.
VB.NET-Quellcode
- <StructLayout(LayoutKind.Sequential, CharSet:=CharSet.[Unicode])>
- Public Structure SHFILEINFOW
- Public hIcon As IntPtr
- Public iIcon As Integer
- Public dwAttributes As Integer
- <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=260)> Public szDisplayName As String
- <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=80)> Public szTypeName As String
- End Structure
- <DllImport("shell32.dll", EntryPoint:="SHGetFileInfoW")>
- Private Shared Function SHGetFileInfoW(<InAttribute(), MarshalAs(UnmanagedType.LPTStr)> ByVal pszPath As String, ByVal dwFileAttributes As Integer, ByRef psfi As SHFILEINFOW, ByVal cbFileInfo As Integer, ByVal uFlags As Integer) As Integer
- End Function
- <DllImport("user32.dll", EntryPoint:="DestroyIcon")>
- Private Shared Function DestroyIcon(ByVal hIcon As System.IntPtr) As <MarshalAs(UnmanagedType.Bool)> Boolean
- End Function
- Private Function GetIcon(ByVal PathName As String) As Bitmap
- Dim RIcon As New SHFILEINFOW
- SHGetFileInfoW(PathName, 0, RIcon, Marshal.SizeOf(RIcon), &H100 Or &H1)
- Dim FinalyImage As Bitmap = Icon.FromHandle(RIcon.hIcon).ToBitmap
- DestroyIcon(RIcon.hIcon)
- Return FinalyImage
- End Function
Nun zu meinem Problem. Wie kann ich jetzt noch zusätzliche Informationen abrufen. Z.b. in welcher Datei ist das Icon gespeichert und welchen Index hat es.
Hoffe auf eure Hilfe.
Grüße TM