icons aus shell32.dll auslesen und speichern

  • Hallo

    Gibt es eine Möglichkeit die Icons aus der shell32.dll auszulesen und zu speichern?

    MfG

    • Offizieller Beitrag

    Du kannst die Icons aus der shell32.dll aber auch direkt in AutoIt einbinden:

    [autoit]


    GUICreate('Test')
    GUICtrlCreateIcon('shell32.dll', -28, 50, 50, 32, 32)
    GUISetState()
    Do
    Until GUIGetMsg() = -3

    [/autoit]

    Und mit diesem Skript (von Progandy) bekommst Du die Nummer des Icons raus:

    Spoiler anzeigen
    [autoit]


    #include<GUIConstants.au3>
    #include<WindowsConstants.au3>
    #include<EditConstants.au3>
    #include<ButtonConstants.au3>
    #include<StaticConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    ;===============================================================================
    ;
    ; Description: Show all icons in the given file and choose one.
    ; Requirement(s): Autoit 3.2.5+
    ; Author(s): Prog@ndy (some Functions and Gui-Style by YDY (Lazycat) (in enumicons_v2))
    ; Version: 1.1
    ; Date: 02.11.2007
    ;
    ; How to Call: $ret = _ChooseIcon( [Optional: Filename] )
    ; Return Values: Array:
    ; [0] = FileName
    ; [1] = Icon Number
    ;
    ;===============================================================================
    $ret = _ChooseIcon()
    MsgBox(0,"Icon","Pfad: " & $ret[0] & @CRLF & "icon-Nr.: " & $ret[1])

    [/autoit] [autoit][/autoit] [autoit]

    Func _ChooseIcon($fFileName = "")

    [/autoit] [autoit][/autoit] [autoit]

    Local $_CI_IconCount, $_CI_FileName, $_CI_SelectedIconName, $_CI_IconRadios[30], $_CI_Labels[30]
    $_CI_oldEventMode = Opt("GuiOnEventMode",0)
    $_CI_StartIndex = 1
    If FileExists($fFileName) Then
    $_CI_FileName = $fFileName
    Else
    $_CI_FileName = @SystemDir & "\shell32.dll"
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    $_CI_hGui=GUICreate("Icon Selector by Ordinal value", 385, 450, -1, -1, -1, $WS_EX_ACCEPTFILES)
    ;GUISetOnEvent($GUI_EVENT_CLOSE,"_CI_CloseFunc")
    GUICtrlCreateGroup("", 5, 1, 375, 40)
    GUICtrlCreateGroup("", 5, 50, 375, 350)
    $_CI_hFile = GUICtrlCreateInput($_CI_FileName, 12, 15, 325, 16, -1, $WS_EX_STATICEDGE)
    GUICtrlSetState(-1, $GUI_DROPACCEPTED)
    GUICtrlSetTip(-1, "You can drop files from shell here...")
    $_CI_hStatus = GUICtrlCreateInput("", 90, 49, 200, 16, $ES_READONLY, $WS_EX_STATICEDGE)
    $_CI_hFileSel = GUICtrlCreateButton("...", 345, 14, 26, 18)
    ;GUICtrlSetOnEvent(-1,"_CI_LoadButton")
    $_CI_Next = GUICtrlCreateButton("&Weiter -|>",310,410)
    ;GUICtrlSetOnEvent(-1,"_CI_Next")
    $_CI_Back = GUICtrlCreateButton("<|- &Zurück",20,410)
    ;GUICtrlSetOnEvent(-1,"_CI_Back")
    $_CI_OK = GUICtrlCreateButton("Icon wählen:",120,410)
    ;GUICtrlSetOnEvent(-1,"_CI_CloseFunc")
    GUICtrlSetState(-1,$GUI_DISABLE)
    $_CI_Icon = GUICtrlCreateIcon("",0,190,404,32,32)

    [/autoit] [autoit][/autoit] [autoit]

    For $iCntRow = 0 to 4
    For $iCntCol = 0 to 5
    $iCurIndex = $iCntRow * 6 + $iCntCol
    $_CI_IconRadios[$iCurIndex] = GUICtrlCreateRadio("", 55 * $iCntCol + 25, 65 * $iCntRow + 75, 45, 45,$BS_ICON+$BS_PUSHLIKE)
    GUICtrlSetImage(-1,@SystemDir & "\shell32.dll",-2)
    ;$ahIcons[$iCurIndex] = GUICtrlCreateIcon($glFilename, 0, 60 * $iCntCol + 25, 70 * $iCntRow + 80)
    ;GUICtrlSetOnEvent(-1,"_CI_SelectedIcon")
    $_CI_Labels[$iCurIndex] = GUICtrlCreateLabel("1", 55 * $iCntCol+12, 65 * $iCntRow + 120, 58, 20, $SS_CENTER)
    GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT )
    Next
    Next

    [/autoit] [autoit][/autoit] [autoit]

    _CI_NewFileLoad($_CI_FileName,$_CI_IconCount, $_CI_hFile)
    _CI_Update($_CI_IconRadios, $_CI_Labels, $_CI_hStatus, $_CI_StartIndex, $_CI_IconCount, $_CI_FileName, $_CI_SelectedIconName)
    GUISetState () ; will display an dialog box with 1 checkbox
    ; Run the GUI until the dialog is closed
    While 1
    $gMsg = GUIGetMsg()
    Switch $gMsg
    Case $_CI_IconRadios[0] To $_CI_IconRadios[29]
    For $i = 0 To 29
    If GUICtrlRead($_CI_IconRadios[$i]) = $GUI_CHECKED Then
    $_CI_SelectedIconName = 1*GUICtrlRead($_CI_Labels[$i])
    GUICtrlSetImage($_CI_Icon,$_CI_FileName,$_CI_SelectedIconName)
    GUICtrlSetState($_CI_OK,$GUI_ENABLE)
    ExitLoop
    EndIf
    Next

    [/autoit] [autoit][/autoit] [autoit]

    Case $_CI_hFileSel
    $_CI_FileName = _CI_NewFileLoad( _
    FileOpenDialog("Select Icon file:", GUICtrlRead($_CI_hFile), "Icon-Files (*.exe;*.dll;*.ocx;*.icl;*.ico)") _
    ,$_CI_IconCount, $_CI_hFile)
    GUICtrlSetState($_CI_Back,$GUI_DISABLE)
    GUICtrlSetState($_CI_OK,$GUI_DISABLE)
    _CI_Update($_CI_IconRadios, $_CI_Labels, $_CI_hStatus, $_CI_StartIndex, $_CI_IconCount, $_CI_FileName, $_CI_SelectedIconName)

    [/autoit] [autoit][/autoit] [autoit]

    Case $_CI_Back
    If $_CI_StartIndex - 30 >= 0 Then $_CI_StartIndex -= 30
    If $_CI_StartIndex - 30 < 0 Then
    GUICtrlSetState($_CI_Back,$GUI_DISABLE)
    EndIf
    GUICtrlSetState($_CI_Next,$GUI_ENABLE)
    _CI_Update($_CI_IconRadios, $_CI_Labels, $_CI_hStatus, $_CI_StartIndex, $_CI_IconCount, $_CI_FileName, $_CI_SelectedIconName)

    [/autoit] [autoit][/autoit] [autoit]

    Case $_CI_Next
    If $_CI_StartIndex + 30 <= $_CI_IconCount Then $_CI_StartIndex += 30
    If $_CI_StartIndex + 30 > $_CI_IconCount Then
    GUICtrlSetState($_CI_Next,$GUI_DISABLE)
    EndIf
    GUICtrlSetState($_CI_Back,$GUI_ENABLE)
    _CI_Update($_CI_IconRadios, $_CI_Labels, $_CI_hStatus, $_CI_StartIndex, $_CI_IconCount, $_CI_FileName, $_CI_SelectedIconName)

    [/autoit] [autoit][/autoit] [autoit]

    Case $GUI_EVENT_CLOSE, $_CI_OK
    ExitLoop
    EndSwitch
    Wend
    GUIDelete($_CI_hGui)
    Opt("GuiOnEventMode",$_CI_oldEventMode)
    Local $arTemp[2] = [$_CI_FileName,$_CI_SelectedIconName]
    Return $arTemp
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _CI_Update(ByRef $_CI_IconRadios, ByRef $_CI_Labels, $_CI_hStatus, $_CI_StartIndex,ByRef $_CI_IconCount, $_CI_FileName, $_CI_SelectedIconName)
    For $iCntRow = 0 to 4
    For $iCntCol = 0 to 5
    $iCurIndex = $iCntRow * 6 + $iCntCol
    If ($iCurIndex + $_CI_StartIndex) > $_CI_IconCount Then
    GUICtrlSetState($_CI_IconRadios[$iCurIndex], $GUI_HIDE)
    GUICtrlSetState($_CI_Labels[$iCurIndex], $GUI_HIDE)
    Else
    GUICtrlSetState($_CI_IconRadios[$iCurIndex], $GUI_SHOW)
    GUICtrlSetState($_CI_Labels[$iCurIndex], $GUI_SHOW)
    GUICtrlSetState($_CI_IconRadios[$iCurIndex],$GUI_UNCHECKED)
    GUICtrlSetImage($_CI_IconRadios[$iCurIndex], $_CI_FileName, -($_CI_StartIndex + $iCurIndex))
    GUICtrlSetData($_CI_Labels[$iCurIndex], -($_CI_StartIndex + $iCurIndex))
    If -($_CI_StartIndex + $iCurIndex) = $_CI_SelectedIconName Then GUICtrlSetState($_CI_IconRadios[$iCurIndex],$GUI_CHECKED)
    EndIf
    Next
    Next
    GUICtrlSetData($_CI_hStatus, "Icons "& $_CI_StartIndex & "-"& _CI_MyMin(($_CI_StartIndex+ 29), $_CI_IconCount)& " von " & $_CI_IconCount _
    & " | Seite "& Ceiling(($_CI_StartIndex)/30)& "von " & Ceiling($_CI_IconCount/30))
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _CI_NewFileLoad($sTmpFile, ByRef $_CI_IconCount, $_CI_hFile)
    If Not FileExists($sTmpFile) Then Return -1
    If @error Then Return -1
    ;$glFileName = $sTmpFile
    GUICtrlSetData($_CI_hFile, $sTmpFile)
    $_CI_iStartIndex = 1
    $_CI_IconCount = _GetIconCount($sTmpFile)
    Return $sTmpFile
    EndFunc

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ; Function by YDY (Lazycat)
    Func _GetIconCount($sFilename)
    Local $iCount= DllCall("Shell32", "int", "ExtractIconEx", "str", $sFilename, "int", -1, "ptr", 0, "ptr", 0, "int", 1)
    If not @error Then Return $iCount[0]
    Return 0
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _CI_MyMin($1,$2)
    If Number($1) < Number($2) Then
    Return Number($1)
    Else
    Return Number($2)
    EndIf
    EndFunc

    [/autoit]
  • Ich würde dir IcoFX empfehlen! Ist ein super Freeware Tools zum Bearbeiten von Icons inkl. das Auslesen von Icons aus DLLs, EXEs, etc.

    Ansonsten kannst du auch mit AutoIt Icons aus DLLs, EXEs, etc. auslesen, darstellen und abspeichern.

    Gruß,
    UEZ

    Auch am Arsch geht ein Weg vorbei...

    ¯\_(ツ)_/¯