Hi Jon,
Thanks for your Feedback.
Here is the latest Update
---------------------------------------------------------------------------------
Drive-Icons Beta 0.815 UPDATE - 08/2011 by Deep-Silence
---------------------------------------------------------------------------------
* Fixed - Loading right values for each Drive
* Fixed - Graphical Elements (language)
* Added - Target Drive is going to be renamed to `%Label`%, silently
* Added - Button to Restart the Script
* Improved - handling of Desktop.ini and Autorun.inf
* Improved - Icon Handling
* Improved - Code cleaned up & more organized
* Improved - Restart Explorer-Shell, silently
---------------------------------------------------------------------------------
With Best Regards,
Deep-Silence
Code:
#NoEnv
#notrayicon
SendMode Input
#SingleInstance, Force
/*
------------------------------------------------------------------------------------------------------------------------------
_ _ _ ____ _ _ _ ____ _ _ ___
| | __ _| |__ ___| |_ / ___| ___| |_| |_(_)_ __ __ _ _ _ _ __ / ___| | | |_ _|
| | / _` | '_ \ / _ \ (_) \___ \ / _ \ __| __| | '_ \ / _` | | | | | '_ \ | | _| | | || |
| |___ (_| | |_) | __/ |_ ___) | __/ |_| |_| | | | | (_| | | |_| | |_) | | |_| | |_| || |
|_____\__,_|_.__/ \___|_(_) |____/ \___|\__|\__|_|_| |_|\__, | \__,_| .__/ \____|\___/|___|
|___/ |_|
------------------------------------------------------------------------------------------------------------------------------
*/
;header gradient
bg=ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
Gui, Font, s14 bold ,terminal
Gui, 1:Add, Text,x0 y0 w840 h4 c0000d0 , %bg%
Gui, 1:Add, Text,y+0 w840 hp c0000c0 , %bg%
Gui, 1:Add, Text,y+0 w840 hp c0000b0 , %bg%
Gui, 1:Add, Text,y+0 w840 hp c0000a0 , %bg%
Gui, 1:Add, Text,y+0 w840 hp c000090 , %bg%
Gui, 1:Add, Text,y+0 w840 hp c000080 , %bg%
Gui, 1:Add, Text,y+0 w840 hp c000070 , %bg%
Gui, 1:Add, Text,y+0 w840 hp c000060 , %bg%
;line blow gradient
gui, add, text, x0 y+0 w840 h2 0x10,
;heading text
gui, font, s14 bold cblack,arial
gui, add, text, x13 y6 +backgroundtrans, Drive-Icons
gui, font, s14 cffffff,arial
gui, add, text, x11 y4 +backgroundtrans, Drive-Icons
;help "button"
gui,add,text,x762 y7 backgroundtrans cblack,?
gui,add,text,x760 y5 backgroundtrans cyellow gHelp,?
gui,add,text,x777 y7 backgroundtrans cblack,+
gui,add,text,x775 y5 backgroundtrans cyellow gHelp_update,+
; --- UI controls ---
;listview
gui,font,,
Gui, Add, ListView, x10 y45 h250 w520 section gListKlick vListe AltSubmit -Multi -LV0x10 NoSort, Drive|Icon|Label|Comment ; Create a ListView.
;Label: editfield & delete button
gui, add, text, ys section, Label:
gui, font, s18 caa0000 normal, wingdings
gui, add, text, y+7 disabled gDelete vdelLabel,û
gui, font,,
gui, add, edit, yp+2 x+2 w150 vedit_label gTextFieldChange,
;Icon: editfield & delete button
gui, add, text, xs y+18, Icon:
gui, font, s18 caa0000 normal, wingdings
gui, add, text, y+7 disabled gDelete vdelIcon,û
gui, font,,
gui, add, edit,yp+2 x+2 w200 vedit_icon gTextFieldChange,
gui, add, button, x+3 yp+1 w25 hp-2 gIconwahl,...
;Hint: editfield
gui, add, text, xs y+18, Comment:
gui, font, s18 caa0000 normal, wingdings
gui, add, text, y+7 disabled gDelete vdelHint,û
gui, font,,
gui, add, edit,yp+2 x+2 w200 vedit_Hint gTextFieldChange,
;Icon: picture & errormessage
gui, add, picture, xs w32 h32 vIcon32,
gui,font,bold c990000,
gui add, text,xp yp vErrorMessage, Error: Icon file not found !
gui,font,,
guicontrol,hide,ErrorMessage
;buttons at bottom
gui, add, text, x0 y310 w840 h2 0x10,
gui, add, button,x670 w120 gbuttoncancel, &Close
gui, add, button,xp-130 w120 gDoIt vDoIt, &Apply
gui, add, button,xp-400 w120 gLabel_Export_Settings, &Export Settings
gui, add, button,xp-130 w120 gLabel_Restart_Explorer, &Restart-Shell
gui, add, button,xp+260 w120 gLabel_Restart, &Restart
;show gui
Gui Show, w800,Drive-Icons
;initalize LV
FirstInit := true
gosub FillDriveList
return
/*
------------------------------------------------------------------------------------------------------------------------------
_ _ _ ___ _ _ ____ _
| | __ _| |__ ___| |_ |_ _|_ __ (_) |_ | _ \ _ __(_)_ _____ ___
| | / _` | '_ \ / _ \ (_) | || '_ \| | __| | | | | '__| \ \ / / _ \ __|
| |___ (_| | |_) | __/ |_ | || | | | | |_ | |_| | | | |\ V / __\__ \
|_____\__,_|_.__/ \___|_(_) |___|_| |_|_|\__| |____/|_| |_| \_/ \___|___/
------------------------------------------------------------------------------------------------------------------------------
*/
FillDriveList:
;create IL and assign to LV.
ImageListID := IL_Create(24,0,0)
LV_SetImageList(ImageListID)
; this LV_ModifyCol command are just cosmetic surgery, when starting the app.
If (FirstInit = true )
{
LV_ModifyCol(1,120)
LV_ModifyCol(2,50)
LV_ModifyCol(3,100)
FirstInit := false
}
DriveGet, LaufwListe, list
AnzLaufw := StrLen(LaufwListe)
StringSplit, Laufwletter, LaufwListe ,,
loop, %AnzLaufw%
{
DriveGet, LaufwTyp%A_Index%, type, % Laufwletter%A_Index% . ":"
if (LaufwTyp%A_Index% = "FIXED") OR (LaufwTyp = "UNKNOWN")
LaufwExIcon%A_Index% := 8+1
if (LaufwTyp%A_Index% = "CDROM")
LaufwExIcon%A_Index% := 11+1
if (LaufwTyp%A_Index% = "REMOVABLE")
LaufwExIcon%A_Index% := 7+1
if (LaufwTyp%A_Index% = "RAMDISK")
LaufwExIcon%A_Index% := 12+1
if (LaufwTyp%A_Index% = "NETWORK")
LaufwExIcon%A_Index% := 9+1
;eleminiate ugly noise from floppy drives (do not retrieve label from possible floppies)
if (Laufwletter%A_Index% <> "A") && (Laufwletter%A_Index% <> "B")
DriveGet, LaufwExLabel%A_Index%, label, % Laufwletter%A_Index% . ":"
DefaultLabel_reg_key := "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DriveIcons\" . Laufwletter%A_Index% . "\DefaultLabel"
RegRead, LaufwMyLabel%A_Index%, HKEY_LOCAL_MACHINE, %DefaultLabel_reg_key%,
DefaultIcon_reg_key := "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DriveIcons\" . Laufwletter%A_Index% . "\DefaultIcon"
RegRead, LaufwMyIcon%A_Index%, HKEY_LOCAL_MACHINE, %DefaultIcon_reg_key%,
DefaultComment_reg_key := "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DriveIcons\" . Laufwletter%A_Index% . "\DefaultComment"
RegRead, LaufwMyHint%A_Index%, HKEY_LOCAL_MACHINE, %DefaultComment_reg_key%,
if (LaufwMyIcon%A_Index% <> "") ; has own icon (specified in registry)
{
IconError%A_Index% := false
IconIndikator := " X "
IconFile := LaufwMyIcon%A_Index%
StripIcon(IconFile,IconIndex)
IconIndex++
; if icon file doesn't exist, create errormessage in LV
; use standard icon in IL
IfNotExist, %IconFile%
{
IconError%A_Index% := true
IL_Add(ImageListID, "shell32.dll",LaufwExIcon%A_Index%)
IconIndikator := "Error !"
}
else ; ok, add icon to IL
{
IL_Add(ImageListID,IconFile,IconIndex )
}
}
else ; no own icon, use standard icon from shell32.dll
{
IconIndikator :=
IL_Add(ImageListID, "shell32.dll", LaufwExIcon%A_Index%)
}
LV_Add("Icon" . A_Index,A_Space Laufwletter%A_Index% . ":" . A_Space LaufwExLabel%A_Index% ,IconIndikator ,LaufwMyLabel%A_Index%, LaufwMyHint%A_Index%)
}
LV_ModifyCol() ; Auto-adjust the column widths.
;select LV item
if (gehezu = "" )
gehezu := 1
LV_Modify(gehezu, "Select")
LV_Modify(gehezu, "Focus")
controlfocus, SysListView321,Drive-Icons
return
/*
------------------------------------------------------------------------------------------------------------------------------
_ _ _ _ _ _ __ ___ _ _ _
| | __ _| |__ ___| |_ | | (_)___| |_ \ / (_) _____ __ / \ ___| |_(_) ___ _ __
| | / _` | '_ \ / _ \ (_) | | | / __| __\ \ / /| |/ _ \ \ /\ / / / _ \ / __| __| |/ _ \| '_ \
| |___ (_| | |_) | __/ |_ | |___| \__ \ |_ \ V / | | __/\ V V / / ___ \ (__| |_| | (_) | | | |
|_____\__,_|_.__/ \___|_(_) |_____|_|___/\__| \_/ |_|\___| \_/\_/ /_/ \_\___|\__|_|\___/|_| |_|
------------------------------------------------------------------------------------------------------------------------------
*/
ListKlick:
; LV item selected, continue with ControlUpdate
if (A_GuiEvent = "DoubleClick")
{
ListenNr = %A_EventInfo%
DefaultLabel =
IconFile =
DefaultComment =
; Reset the Last Values
VarSetCapacity(DefaultLabel_Value,0)
VarSetCapacity(This_DriveLetter,0)
VarSetCapacity(IconFile_Value,0)
VarSetCapacity(DefaultComment_Value,0)
VarSetCapacity(IconFile,0)
;guicontrol,,edit_label, %DefaultLabel_Value%
;guicontrol,,edit_icon, %This_DriveLetter%%IconFile_Value%
;guicontrol,,edit_hint, %DefaultComment_Value%
;guicontrol,,Icon32, %IconFile%
;=================================================================
;Update editfields, icon/errormassage and delete buttons, matching the selected drive from LV
ControlUpdate:
VarSetCapacity(Check_Drive,0) ; Check_Drive Zurücksetzen
LV_GetText(Check_Drive, A_EventInfo, 1) ; Check_Drive auslesen
; Exclude Drive A from the Action
IfEqual, ListenNr, "1"
Goto, NoAction
; Failure-Correction for "Dr"
IfEqual, Check_Drive, "Dr"
Goto, NoAction
; Isolation of DriveLetter from "%Check_Drive%"
Check_Drive = %Check_Drive%
StringLeft, Check_Drive, Check_Drive, 2
StringLeft, D_Letter, Check_Drive, 1
;Msgbox, Check_Drive: %Check_Drive%`nD_Letter: %D_Letter%
; Auslesen der Werte aus "Autorun.inf" falls vorhanden
IfExist, %Check_Drive%\AutoRun.inf
{
IniRead, IconFile_Value, %Check_Drive%\AutoRun.inf, autorun, Icon
IniRead, DefaultLabel_Value, %Check_Drive%\AutoRun.inf, autorun, Label
This_DriveLetter = %Check_Drive%\
}
If (IconFile_Value = "") Or (DefaultLabel_Value = "")
{
IconFile = SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DriveIcons\%D_Letter%\DefaultIcon\
RegRead, IconFile_Value, HKEY_LOCAL_MACHINE, %IconFile%,
DefaultLabel = SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DriveIcons\%D_Letter%\DefaultLabel\
RegRead, DefaultLabel_Value, HKEY_LOCAL_MACHINE, %DefaultLabel%,
;Msgbox, IconFile_Value: %IconFile_Value%`nDefaultLabel_Value: %DefaultLabel_Value%
This_DriveLetter =
}
; Auslesen der Werte aus "Desktop.ini" falls vorhanden
IfExist, %Check_Drive%\Desktop.ini
{
IniRead, DefaultComment_Value, %Check_Drive%\Desktop.ini, .ShellClassInfo, InfoTip
}
Else
{
DefaultComment = SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DriveIcons\%D_Letter%\DefaultComment\
RegRead, DefaultComment_Value, HKEY_LOCAL_MACHINE, %DefaultComment%,
}
If (DefaultComment_Value = "") Or (DefaultComment_Value = Error)
{
DefaultComment = SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DriveIcons\%D_Letter%\DefaultComment\
RegRead, DefaultComment_Value, HKEY_LOCAL_MACHINE, %DefaultComment%,
}
;Writing Values to File for debugging
;FileAppend , DefaultLabel: %DefaultLabel%`nIconFile: %IconFile%`nDefaultComment: %DefaultComment%`n`n`n, Debug.txt
;IconFile = %This_DriveLetter%%IconFile_Value%
IconFile = %IconFile_Value%
LaufwMyIcon%ListenNr% := IconFile
;Msgbox, %IconFile%
;guicontrol,,edit_icon, %This_DriveLetter%%IconFile_Value%
guicontrol,,edit_label, %DefaultLabel_Value%
guicontrol,,edit_icon, %IconFile_Value%
guicontrol,,edit_hint, %DefaultComment_Value%
guicontrol,,Icon32, %IconFile_Value%
;IconFile = %Check_Drive%%IconFile_Value%
;IconFile2 := LaufwMyIcon%ListenNr%
StripIcon(IconFile,IconIndex)
IconIndex ++
if (LaufwMyIcon%ListenNr% <> "")
{
guicontrol,enable,delIcon
if (IconError%ListenNr% = true)
{
guicontrol,hide,Icon32
guicontrol,show,ErrorMessage
}
else
{
guicontrol,hide,ErrorMessage
guicontrol,show,Icon32
guicontrol,,Icon32, *icon%iconindex% *w32 *h32 %IconFile%
}
}
else
{
guicontrol,hide,Icon32
guicontrol,hide,ErrorMessage
guicontrol,disable,delIcon
}
if (LaufwMyLabel%ListenNr% <> "")
{
guicontrol,enable,delLabel
}
else
{
guicontrol,disable,delLabel
}
if (LaufwMyLabel%ListenNr% <> "")
{
guicontrol,enable,delHint
}
else
{
guicontrol,disable,delHint
}
guicontrol,disable, DoIt
}
NoAction:
return
/*
------------------------------------------------------------------------------------------------------------------------------
_ _ _ _____ _ _____ _ _ _ ____ _
| | __ _| |__ ___| |_ |_ _|____ __ |_| ___(_) ___| | __| | / ___| |__ __ _ _ __ __ _ ___ ___
| | / _` | '_ \ / _ \ (_) | |/ _ \ \/ / __| |_ | |/ _ \ |/ _` | | | | '_ \ / _` | '_ \ / _` |/ _ \ __|
| |___ (_| | |_) | __/ |_ | | __/> <| |_| _| | | __/ | (_| | | |___| | | | (_| | | | | (_| | __\__ \
|_____\__,_|_.__/ \___|_(_) |_|\___/_/\_\\__|_| |_|\___|_|\__,_| \____|_| |_|\__,_|_| |_|\__, |\___|___/
|___/
------------------------------------------------------------------------------------------------------------------------------
*/
TextFieldChange:
GuiControlGet, wert, , %A_GuiControl%
if (A_GuiControl = "edit_label")
{
if (LaufwMyLabel%ListenNr% <> wert)
guicontrol,enable, DoIt
if (strlen(wert) = 0)
guicontrol,disable,delLabel
if (strlen(wert) > 0)
guicontrol,enable,delLabel
}
if (A_GuiControl = "edit_icon")
{
if (LaufwMyIcon%ListenNr% <> wert)
guicontrol,enable, DoIt
if (strlen(wert) = 0)
guicontrol,disable,delIcon
if (strlen(wert) > 0)
guicontrol,enable,delIcon
}
if (A_GuiControl = "edit_Hint")
{
if (LaufwMyHint%ListenNr% <> wert)
guicontrol,enable, DoIt
if (strlen(wert) = 0)
guicontrol,disable,delHint,
if (strlen(wert) > 0)
guicontrol,enable,delHint,
}
return
/*
------------------------------------------------------------------------------------------------------------------------------
_ _ _ _ _ _ _ ___ _ _ _ _
| | __ _| |__ ___| |_ | | | |_ __ __| | __ _| |_ ___ |_ _|___ ___ _ __ __ _ _ __ __| | | | __ _| |__ ___| |
| | / _` | '_ \ / _ \ (_) | | | | '_ \ / _` |/ _` | __/ _ \ | |/ __/ _ \| '_ \ / _` | '_ \ / _` | | | / _` | '_ \ / _ \ |
| |___ (_| | |_) | __/ |_ | |_| | |_) | (_| | (_| | |_ __/ | | (__ (_) | | | | | (_| | | | | (_| | | |___ (_| | |_) | __/ |
|_____\__,_|_.__/ \___|_(_) \___/| .__/ \__,_|\__,_|\__\___| |___\___\___/|_| |_| \__,_|_| |_|\__,_| |_____\__,_|_.__/ \___|_|
|_|
------------------------------------------------------------------------------------------------------------------------------
*/
; delete icon and/or label in editfield
Delete:
if (A_GuiControl = "delLabel")
{
guicontrol,,edit_label,
guicontrol,disable,delLabel
}
if (A_GuiControl = "delIcon")
{
guicontrol,,edit_icon,
guicontrol,hide,Icon32
guicontrol,disable,delIcon
}
if (A_GuiControl = "delHint")
{
guicontrol,,edit_hint,
guicontrol,hide,Icon32
guicontrol,disable,delHint
}
return
/*
------------------------------------------------------------------------------------------------------------------------------
_ _ _ _____ _ ____ _ _ _
| | __ _| |__ ___| |_ | ____|_ ___ __ ___ _ __| |_ / ___| ___| |_| |_(_)_ __ __ _ ___
| | / _` | '_ \ / _ \ (_) | _| \ \/ / '_ \ / _ \| '__| __| \___ \ / _ \ __| __| | '_ \ / _` / __|
| |___ (_| | |_) | __/ |_ | |___ > <| |_) | (_) | | | |_ ___) | __/ |_| |_| | | | | (_| \__ \
|_____\__,_|_.__/ \___|_(_) |_____/_/\_\ .__/ \___/|_| \__| |____/ \___|\__|\__|_|_| |_|\__, |___/
|_| |___/
------------------------------------------------------------------------------------------------------------------------------
*/
Label_Export_Settings:
EnvGet, This_Computer, Computername
FileSelectFile, Outputfile,S 2,::{20d04fe0-3aea-1069-a2d8-08002b30309d}\%This_Computer%_DriveSettings.reg , Where to save?, Registry-Settings (*.reg)
if Outputfile =
MsgBox, Saving aborted!
else
{
;Msgbox, %Outputfile%
RunWait, %comspec% /c "REG EXPORT HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DriveIcons %Outputfile%",, Hide
}
Return
/*
------------------------------------------------------------------------------------------------------------------------------
_ _ _ ____ _ _ _____ _ ____ _ _ _
| | __ _| |__ ___| |_ | _ \ ___ ___| |_ __ _ _ __| |_ | ____|_ ___ __ | | ___ _ __ ___ _ __ / ___|| |__ ___| | |
| | / _` | '_ \ / _ \ (_) | |_) / _ \ __| __/ _` | '__| __| | _| \ \/ / '_ \| |/ _ \| '__/ _ \ '__| \___ \| '_ \ / _ \ | |
| |___ (_| | |_) | __/ |_ | _ < __\__ \ |_ (_| | | | |_ | |___ > <| |_) | | (_) | | | __/ | ___) | | | | __/ | |
|_____\__,_|_.__/ \___|_(_) |_| \_\___|___/\__\__,_|_| \__| |_____/_/\_\ .__/|_|\___/|_| \___|_| |____/|_| |_|\___|_|_|
|_|
------------------------------------------------------------------------------------------------------------------------------
*/
Label_Restart_Explorer:
Msgbox_Text =
(Ltrim
For the Changes to take affect, you
need to restart the Explorer-Shell!
Do you really want to do that?
All open Folders will be lost!
)
MsgBox, 4, Restart Explorer-Shell, %Msgbox_Text%,
IfMsgBox, Yes
{
Runwait, %comspec% /c "taskkill -f -im explorer.exe" , , hide
Run, explorer.exe
}
Else
{
; Do Nothing
}
Return
/*
------------------------------------------------------------------------------------------------------------------------------
_ _ _ ____ __ ___
| | __ _| |__ ___| |_ | __ ) _ __ _____ _____ ___ / _| ___ _ __ |_ _|___ ___ _ __
| | / _` | '_ \ / _ \ (_) | _ \| '__/ _ \ \ /\ / / __|/ _ \ | |_ / _ \| '__| | |/ __/ _ \| '_ \
| |___ (_| | |_) | __/ |_ | |_) | | | (_) \ V V /\__ \ __/ | _| (_) | | | | (__ (_) | | | |
|_____\__,_|_.__/ \___|_(_) |____/|_| \___/ \_/\_/ |___/\___| |_| \___/|_| |___\___\___/|_| |_|
------------------------------------------------------------------------------------------------------------------------------
*/
Iconwahl:
Gui, submit,nohide
IconFile := edit_icon
IconIndex := 0
StripIcon(IconFile,IconIndex)
gui, +disabled
ChooseIcon(IconFile, IconIndex, hGui)
gui, -disabled
gui, show
if instr(IconFile,"%SystemRoot%" )
{
StringReplace, IconFile, IconFile, % "%SystemRoot%", %A_WinDir% , All
}
guicontrol,show,Icon32
guicontrol,,Icon32, % "*icon" . IconIndex+1 . " *w32 *h32 " . IconFile
guicontrol,enable,delIcon
guicontrol,hide,ErrorMessage
IconIndexText =
if (IconIndex <> 0)
IconIndexText = ,%IconIndex%
GuiControl,,edit_icon, %IconFile%%IconIndexText%
return
;=================================================================
;split iconstring into filename and index
StripIcon(byRef IconFile, byRef IconIndex)
{
find = ,
StringGetPos, KommaPos, IconFile, %find%, R
if (KommaPos > 0)
{
IconIndex := SubStr(IconFile, KommaPos+2)
StringLeft,IconFile,IconFile,KommaPos
}
else
{
IconIndex := 0
}
Return
}
DeleteHint:
Return
/*
------------------------------------------------------------------------------------------------------------------------------
_ _ _ _ _ ____ _
| | __ _| |__ ___| |_ / \ _ __ _ __ | |_ _ / ___| |__ __ _ _ __ __ _ ___ ___ _
| | / _` | '_ \ / _ \ (_) / _ \ | '_ \| '_ \| | | | | | | | '_ \ / _` | '_ \ / _` |/ _ \ __(_)
| |___ (_| | |_) | __/ |_ / ___ \| |_) | |_) | | |_| | | |___| | | | (_| | | | | (_| | __\__ \_
|_____\__,_|_.__/ \___|_(_) /_/ \_\ .__/| .__/|_|\__, | \____|_| |_|\__,_|_| |_|\__, |\___|___(_)
|_| |_| |___/ |___/
------------------------------------------------------------------------------------------------------------------------------
*/
DoIt:
VarSetCapacity(Label_Drive,0)
VarSetCapacity(edit_label,0)
gui, submit, nohide
/*
This_Drive = "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DriveIcons\%D_Letter%"
DefaultLabel_reg_key = "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DriveIcons\%D_Letter%\DefaultLabel"
Msgbox, Check_Drive: %Check_Drive%`nD_Letter: %D_Letter%`n`nDefaultLabel_reg_key: %DefaultLabel_reg_key%`n`nThis_Drive: %This_Drive%
ExitApp
*/
;################################################################
; Label the Disk
;################################################################
StringTrimRight, Label_Drive, Check_Drive, 1
Runwait, %comspec% /c "label %Label_Drive%: %edit_label%",, Hide
;################################################################
; Processing the Data for "DefaultLabel"
;################################################################
DefaultLabel_reg_key = SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DriveIcons\%D_Letter%\DefaultLabel
If (edit_label = "")
{
RegDelete, HKEY_LOCAL_MACHINE, %DefaultLabel_reg_key%
}
Else
{
RegWrite,REG_SZ , HKEY_LOCAL_MACHINE, %DefaultLabel_reg_key%,, %edit_label%
;IniWrite, %empty%, %Check_Drive%Autorun.inf, autorun, Label
}
;################################################################
; Processing the Data for "DefaultIcon"
;################################################################
DefaultIcon_reg_key = SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DriveIcons\%D_Letter%\DefaultIcon
If (edit_icon = "")
{
RegDelete, HKEY_LOCAL_MACHINE, %DefaultIcon_reg_key%
}
Else
{
RegWrite, REG_SZ, HKEY_LOCAL_MACHINE, %DefaultIcon_reg_key%, ,%edit_icon%
;IniWrite, %empty%, %Check_Drive%\Autorun.inf, autorun, Icon
}
;################################################################
; Processing the Data for "DefaultComment"
;################################################################
DefaultComment_reg_key = SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DriveIcons\%D_Letter%\DefaultComment
If (edit_icon = "")
{
RegDelete, HKEY_LOCAL_MACHINE, %DefaultComment_reg_key%
}
Else
{
RegWrite, REG_SZ, HKEY_LOCAL_MACHINE, %DefaultComment_reg_key%, ,%edit_Hint%
}
;################################################################
; Updating necessary Files
;################################################################
FileDelete, %Check_Drive%\Desktop.ini
FileDelete, %Check_Drive%\Autorun.inf
;Desktop.ini - Template
Desktop_Ini_Template =
(Ltrim
[.ShellClassInfo]
IconFile=
IconIndex=
InfoTip=%edit_Hint%
)
FileAppend, %Desktop_Ini_Template%, %Check_Drive%\DESKTOP.INI
;Autorun.inf - Template
Autorun_inf_Template =
(Ltrim
[autorun]
Label=%edit_label%
Icon=%edit_icon%
)
FileAppend, %Autorun_inf_Template%, %Check_Drive%\AUTORUN.INF
;################################################################
; All Edits are Empty
;################################################################
If (edit_label = "") && (edit_icon = "") && (edit_hint = "")
{
This_Drive = SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DriveIcons\%D_Letter%
RegDelete, HKEY_LOCAL_MACHINE, %This_Drive%
}
If (edit_hint = "")
{
FileDelete, %Check_Drive%Desktop.ini
FileDelete, %Check_Drive%Desktop.in_
RegWrite, REG_SZ, HKEY_LOCAL_MACHINE, %DefaultComment_reg_key%, ,%empty%
}
;################################################################
; Update Listview
;################################################################
IL_Destroy(ImageListID)
LV_Delete()
guicontrol,disable, DoIt
gehezu := ListenNr
gosub FillDriveList
guicontrol,,edit_label,
guicontrol,,edit_icon,
guicontrol,,edit_hint,
guicontrol,,Icon32,
return
/*
------------------------------------------------------------------------------------------------------------------------------
_ _ _ _ _ _
| | __ _| |__ ___| |_ | | | | ___| |_ __
| | / _` | '_ \ / _ \ (_) | |_| |/ _ \ | '_ \
| |___ (_| | |_) | __/ |_ | _ | __/ | |_) |
|_____\__,_|_.__/ \___|_(_) |_| |_|\___|_| .__/
|_|
------------------------------------------------------------------------------------------------------------------------------
*/
Help:
gui +owndialogs
msgbox,
(
Drive-Icons Beta 0.815 - 2007 by Markus Möller
This little App allows you to change the icon and the label for a drive.
It is very usefull if you've got many partitions, virtual cd drives, multi card
reader etc.
Use icons and descriptions for your drives to make it easier to detect them in
the windows explorer.
If you have choosen an icon and/or label for a cd-rom drive it will shown as long
as no disc is inserted. When you insert a disc into the drive, you will see the
icon and label specified in the autorun.inf.
If a disc has a "real label" it will used prior to what you typed into the label
field of this app.
Sorry about the name confusing about label and label. I'll try to find better
words for the next release. ;-)
You can extend the limitations of naming a fat partition, if you don't give a
"real label" with the windows explorer, or using the label command.
2Do:
Adding ability to work with non present drives.
Multilanguage support (De/En)
Maybe a feature to disable drives (like TweakUI)
)
return
/*
------------------------------------------------------------------------------------------------------------------------------
_ _ _ _ _ _ _ _ _ _
| | __ _| |__ ___| |_ | | | | ___| |_ __ | | | |_ __ __| | __ _| |_ ___
| | / _` | '_ \ / _ \ (_) | |_| |/ _ \ | '_ \ _____ | | | | '_ \ / _` |/ _` | __/ _ \
| |___ (_| | |_) | __/ |_ | _ | __/ | |_) | |_____| | |_| | |_) | (_| | (_| | |_ __/
|_____\__,_|_.__/ \___|_(_) |_| |_|\___|_| .__/ \___/| .__/ \__,_|\__,_|\__\___|
|_| |_|
------------------------------------------------------------------------------------------------------------------------------
*/
Help_update:
msgbox,
(ltrim
---------------------------------------------------------------------------------
Drive-Icons Beta 0.815 UPDATE - 2010 by Deep-Silence
---------------------------------------------------------------------------------
Additionals:
* Comment-Column
This Comment is shown in Windows-Explorer for a Description
* Support for Autorun.inf and Desktop.ini. If those files are present
"Icon" and "Label" are read out of Autorun.inf & "Comment" is read out
of Desktop.ini
* Button to restart Explorer-Shell For "Comments" to be shown in Explorer
* Button to export the Settings for all Drives. Makes it easier to import
them after a reinstallation of Windows.
* Some GUI-Adjustments
---------------------------------------------------------------------------------
Drive-Icons Beta 0.815 UPDATE - 08/2011 by Deep-Silence
---------------------------------------------------------------------------------
* Fixed - Loading right values for each Drive
* Fixed - Graphical Elements (language)
* Added - Target Drive is going to be renamed to `%Label`%, silently
* Added - Button to Restart the Script
* Improved - handling of Desktop.ini and Autorun.inf
* Improved - Icon Handling
* Improved - Code cleaned up & more organized
* Improved - Restart Explorer-Shell, silently
---------------------------------------------------------------------------------
[NOTES]
These Code-Adjustments might still contain some Bugs.
Tested under Windows XP SP3 German, only.
Best Regards,
Deep-Silence
)
Return
/*
------------------------------------------------------------------------------------------------------------------------------
_ _ _ _____ _ _ _ _ _ _ _
| | __ _| |__ ___| |_ | ____|_ ___) |_ / \ _ __ _ __ | (_) ___ __ _| |_(_) ___ _ __
| | / _` | '_ \ / _ \ (_) | _| \ \/ / | __| / _ \ | '_ \| '_ \| | |/ __/ _` | __| |/ _ \| '_ \
| |___ (_| | |_) | __/ |_ | |___ > <| | |_ / ___ \| |_) | |_) | | | (__ (_| | |_| | (_) | | | |
|_____\__,_|_.__/ \___|_(_) |_____/_/\_\_|\__| /_/ \_\ .__/| .__/|_|_|\___\__,_|\__|_|\___/|_| |_|
|_| |_|
------------------------------------------------------------------------------------------------------------------------------
*/
buttoncancel:
GuiClose:
exitapp
Label_Restart:
Reload
return
/*
------------------------------------------------------------------------------------------------------------------------------
_____ _ _ _ _ ____ _____ ___ ___ _ _ ____
| ___| | | | \ | |/ ___|_ _|_ _/ _ \| \ | / ___|_
| |_ | | | | \| | | | | | | | | | \| \___ (_)
| _| | |_| | |\ | |___ | | | | |_| | |\ |___) |
|_| \___/|_| \_|\____| |_| |___\___/|_| \_|____(_)
------------------------------------------------------------------------------------------------------------------------------
*/
; ChooseIcon by majkinetor, w2k fix by me
ChooseIcon(ByRef sIcon, ByRef idx, hGui=0) {
VarSetCapacity(wIcon, 1025, 0)
if sIcon !=
{
r := DllCall("MultiByteToWideChar"
, "UInt", 0 ; CodePage: CP_ACP=0 (current Ansi), CP_UTF7=65000, CP_UTF8=65001
, "UInt", 0 ; dwFlags
, "Str", sIcon ; LPSTR lpMultiByteStr
, "Int", StrLen(sIcon) ; cbMultiByte: -1=null terminated
, "UInt", &wIcon ; LPCWSTR lpWideCharStr
, "Int", 1025) ; cchWideChar: 0 to get required size
if !r
return 2
}
r := DllCall(DllCall("GetProcAddress", "Uint", DllCall("LoadLibrary", "str", "shell32.dll"), "Uint", 62), "uint", hGui, "uint", &wIcon, "uint", 1025, "intp", idx)
if !r
return 1
len := DllCall("lstrlenW", "UInt", &wIcon)
VarSetCapacity(sIcon, len, 0)
r := DllCall("WideCharToMultiByte"
, "UInt", 0 ; CodePage: CP_ACP=0 (current Ansi), CP_UTF7=65000, CP_UTF8=65001
, "UInt", 0 ; dwFlags
, "UInt", &wIcon ; LPCWSTR lpWideCharStr
, "Int", len ; cchWideChar: size in WCHAR values, -1=null terminated
, "Str", sIcon ; LPSTR lpMultiByteStr
, "Int", len ; cbMultiByte: 0 to get required size
, "UInt", 0 ; LPCSTR lpDefaultChar
, "UInt", 0) ; LPBOOL lpUsedDefaultChar
if !r
return 3
return 0
}