Icons extrahieren

    • VB.NET

    Es gibt 1 Antwort in diesem Thema. Der letzte Beitrag () ist von Beep!.

      Icons extrahieren

      Hier mal eine Alternative zu [Allgemein] Icons aus exe, dll oder ico extrahieren/verwenden

      VB.NET-Quellcode

      1. Public Declare Function DestroyIcon Lib "User32.dll" (ByRef phicon As IntPtr) As Boolean
      2. Public Declare Function ExtractIconEx Lib "shell32.dll" (ByVal lpszFile As String, ByVal nIconIndex As Integer, _
      3. ByRef phiconLarge As IntPtr, ByRef phiconSmall As IntPtr, ByVal nIcons As Integer) As IntPtr
      4. Public Function GetApplicationIcon(ByVal Filepath As String, ByVal smallIcon As Boolean, Optional ByVal NrOfIcon As Integer = 0) As Icon
      5. Dim iconPtr As IntPtr
      6. Dim myIcon As Icon
      7. If smallIcon = True Then
      8. ExtractIconEx(Filepath, NrOfIcon, Nothing, iconPtr, 1)
      9. Else
      10. ExtractIconEx(Filepath, NrOfIcon, iconPtr, Nothing, 1)
      11. End If
      12. Try
      13. myIcon = Icon.FromHandle(iconPtr)
      14. Catch ex As Exception
      15. Return Nothing
      16. End Try
      17. DestroyIcon(iconPtr)
      18. Return myIcon
      19. End Function


      Beispiel:

      VB.NET-Quellcode

      1. PictureBox1.Image = GetApplicationIcon(Application.ExecutablePath, True).ToBitmap



      (umgeschrieben von Dominique Vandensteen's Code)
      Für ein Mindestmaß an Rechtschreibung, Interpunktion und Majuskeln!

      Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „bla“ ()