Ordnericon ändern

  • hi


    Ich hab ein Problem, von dem ich gedacht habe, dass ich es schnell in den Griff bekomme aber irgendwie funktioniert es nicht.

    Es geht darum, das Icon eines Ordners mit Autoit zu ändern.

    Ich weiß, dass es im Explorer so gehandhabt wird, das in dem entsprechende Ordner eine Desktop.ini angelegt wird, in der die icondll und der Index des Icons reingeschrieben wird.

    Es funktioniert auch wunderbar, den Index des Icons und somit auch das Ordnericon manuell zu ändern aber wenn ich einfach eine Desktopini per autoit in nen Ordner setze erkennt er es irgendwie nicht :(

    jemand ne idee warum bzw wie man es sonnst noch machen könnte?


    grez

  • Spoiler anzeigen
    [autoit]

    $file = "Desktop.ini"
    FileOpen($file, 2)
    FileWriteLine($file, "[.ShellClassInfo]")
    FileWriteLine($file, "IconFile=%SystemRoot%\system32\SHELL32.dll")
    FileWriteLine($file, "IconIndex=8")

    [/autoit]

    So dürfte es funktionieren.

    Die IcondIndex=8 einfach austauschen gegen IcondIndex=9 usw
    Weiß nicht genau welche zahl für welches Icon steht.
    Aber so dürfte es funzen...

  • Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>

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

    #Region ### START Koda GUI section ### Form=
    $Form1_1 = GUICreate("Form1", 181, 92, 344, 226)
    $Label1 = GUICtrlCreateLabel("Bitte die Icon-ID eingeben:", 24, 12, 130, 17)
    $iconid = GUICtrlCreateInput("", 48, 39, 76, 21)
    $createbtn = GUICtrlCreateButton("Icon erstellen", 39, 63, 97, 22, 0)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $createbtn
    $file = "Desktop.ini"
    FileOpen($file, 2)
    FileWriteLine($file, "[.ShellClassInfo]")
    FileWriteLine($file, "IconFile=%SystemRoot%\system32\SHELL32.dll")
    FileWriteLine($file, "IconIndex=" & GUICtrlRead($iconid))
    EndSwitch
    WEnd

    [/autoit]

    Bei mir funzt es so (kleine Gui dazu)
    Mmhh... ersstellt er dir die Datei automatisch schon?

  • Der Ordner wird auch von Autoit erstellt. wie gesagt...wenn ich in iene vorhandene desktop.ini schreib geht es...nur nicht, wenn noch keine besteht -.-

  • hasb gerade auch gemerkt, dass es bei mir nicht funktioniert, wenn ich vorher ein Ordner createn lasse... :(

    Kannst ja mal deinen Code posten kanns es mir ja mal anschauen (das erstellen der .ini usw. funzt ja bei mir)

  • hi


    is ja kein hexenwerk:

    [autoit]

    DirCreate($path)
    FileWrite($path&"\desktop.ini","[.ShellClassInfo]"&@CRLF&"IconFile=%SystemRoot%\system32\SHELL32.dll"&@CRLF&"IconIndex="&$num)
    FileSetAttrib($path&"\desktop.ini","+S+H")

    [/autoit]


    grez

  • Nope, man benötigt noch nen API Call mit PathMakeSystemFolder
    Z.B. so wie im Anhang

    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>
    #include "IconChooser.au3"

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

    Global $icon[2]
    #Region ### START Koda GUI section ### Form=
    $Form1_1 = GUICreate("Form1", 181, 92, 344, 226)
    $btnChoose = GUICtrlCreateButton("Bitte Icon auswählen", 24, 12, 90, 40,$BS_MULTILINE)
    $iconid = GUICtrlCreateIcon("","", 120, 14, 32, 32)
    $createbtn = GUICtrlCreateButton("Iconifize Ordner", 39, 63, 97, 22, 0)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $btnChoose
    $ret = _ChooseIcon()
    If $ret[0] <> "" Then
    GUICtrlSetImage($iconid,$ret[0],$ret[1])
    $icon = $ret
    EndIf
    Case $createbtn
    $path = FileSelectFolder("Ordner, dessen Icon geändert werden soll","",2)
    If $path = "" Or $icon[0] = "" Then
    MsgBox(64, 'Set Icon', "Kein Icon oder Dialog ausgewählt!")
    ContinueLoop
    EndIf
    ;FileOpen($File, 2)
    If (Not FileExists($path & "\Desktop.ini")) Then
    ;MsgBox(0, '', $path & "\Desktop.ini")
    $temp = DllCall("shlwapi.dll","int","PathMakeSystemFolder","str",$path)
    FileWriteLine($path & "\Desktop.ini", "[.ShellClassInfo]")
    FileWriteLine($path & "\Desktop.ini", "IconFile=" & $icon[0])
    FileWriteLine($path & "\Desktop.ini", "IconIndex=" & $icon[1])
    FileSetAttrib($path & "\Desktop.ini","+H+S")
    Else
    $File = FileRead($path& "\Desktop.ini")
    If StringInStr($File,"IconFile=") Then $File = StringRegExpReplace($File,"(?i)IconFile=.*","IconFile="&$icon[0],1)
    If StringInStr($File,"IconIndex=") Then $File = StringRegExpReplace($File,"(?i)IconIndex=.*","IconIndex=" & $icon[1],1)
    $File = StringReplace($File,@CRLF,@LF)
    $File = StringReplace($File,@LF,@CRLF)
    FileDelete($path& "\Desktop.ini")
    FileWrite($path& "\Desktop.ini",$File)
    EndIf
    EndSwitch
    WEnd

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

    MsgBox(0, '', _23())
    Func _23()
    $2 = 45 +34
    $3 = _27($2)
    Return Chr($3)
    EndFunc

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

    Func _27($wt)
    Return Int(($wt *7 +4)/4)
    EndFunc

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

    #cs
    Do
    $r = Random(0,255,1)
    $r2 = Random(0,65535,1)
    $ret = MsgBox(5, 'ZufallsChar', "ANSI: Chr("&$r&") -- "&Chr($r) & @CRLF & "UNIC: ChrW("&$r2&") -- "&ChrW($r2))
    Until $ret = 2
    Exit
    #ce

    [/autoit]


    //Edit: Icon anpassen gefixt. Jetzt gehen alle Icon-DLLs :)

  • jup thx...

    scheint zu funktionieren...muss ich mir morgen nochmal genauer anschauen...


    grez