Jump to content

Drive Icon Changer ( Not .inf )


YawStar
 Share

Recommended Posts

And The source code is here..

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <Constants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <Misc.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <TabConstants.au3>


If _Singleton("YawStar Drive Icon Changer", 1) = 0 Then
    MsgBox(16, "Warning", "YawStar Drive Icon Changer is already running.", 5)
    Exit
EndIf

#Region Main GUI
DirCreate(@AppDataDir & "\YawStar\YawStar Drive Icon Changer\Icons")
FileInstall("Resources\Icons\MainIcon.ico", @AppDataDir & "\YawStar\YawStar Drive Icon Changer\Icons\MainIcon.ico", 1)
DirCreate(@AppDataDir & "\YawStar\YawStar Drive Icon Changer\Images")
$AppTitle = "YawStar Drive Icon Changer"
$YS_DIcon_Changer = GUICreate($AppTitle, 349, 285, -1, -1, $WS_SYSMENU)
;About button
$btnAbout = GUICtrlCreateButton("!", 320, 0, 20, 20)
GUICtrlSetCursor(-1, 0)
GUICtrlSetTip(-1, "About...", "", $TIP_NOICON, $TIP_BALLOON)

; Group
$Group1 = GUICtrlCreateGroup("", 8, 16, 329, 177)
;Label Chose Icon
$LblIconChose = GUICtrlCreateLabel("Chose Icon", 24, 26, 58, 17)
;Input Icon Location
$NputIconLocation = GUICtrlCreateInput("", 24, 46, 241, 21)
;Browse Icon Button
$btnIconBrowse = GUICtrlCreateButton("...", 272, 44, 57, 25)
GUICtrlSetFont(-1, 12, 800, 0, "Arial")
GUICtrlSetCursor(-1, 0)
GUICtrlSetTip(-1, "Browse Icon...", "", $TIP_NOICON, $TIP_BALLOON)
;Label Chose Drives
$LblChoseDrive = GUICtrlCreateLabel("Chose Drive", 25, 79, 62, 17)
;Drives Latters ComboBox
Local $CboDLatter = GUICtrlCreateCombo("", 24, 104, 121, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlSetData($CboDLatter, "A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z", "D")

;IconImage
$IconPic = GUICtrlCreateIcon(@AppDataDir & "\YawStar\YawStar Drive Icon Changer\Icons\MainIcon.ico", 0, 230, 90, 90, 90)

; Restore  Default Button
$btnRestore = GUICtrlCreateButton("Restore Default", 16, 208, 105, 41)
GUICtrlSetCursor(-1, 0)
GUICtrlSetTip(-1, "Restore Default Icon...", "", $TIP_NOICON, $TIP_BALLOON)

; Change Drive Icon Button
$btnChange = GUICtrlCreateButton("Change Drive Icon", 230, 208, 105, 41)
GUICtrlSetCursor(-1, 0)
GUICtrlSetTip(-1, "Change Icon...", "", $TIP_NOICON, $TIP_BALLOON)

GUISetState(@SW_SHOW)
#EndRegion

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $btnIconBrowse
            $icoopen = FileOpenDialog("Choose an icon file", @DesktopDir, "Icon (*.ico)", 1)
            GUICtrlSetData($NputIconLocation, $icoopen)
            GUICtrlCreateIcon($icoopen, 0,230, 90, 90, 90)
            GUICtrlCreateIcon(@AppDataDir & "\YawStar\YawStar Drive Icon Changer\Icons\MainIcon.ico", 0, 230, 90, 90, 90)
        Case $btnChange
            $IconPath = GUICtrlRead($NputIconLocation)
            If $IconPath = "" Then
                MsgBox(16, "Icon is not found ..", "Please choose a icon ..")
            Else
                $DriveLatter = GUICtrlRead($CboDLatter,0)
                FileDelete(@AppDataDir & "\YawStar\YawStar Drive Icon Changer\Icons\" & $DriveLatter & ".ico")
                RegDelete("HKEY_CURRENT_USER\Software\Classes\Applications\Explorer.exe\Drives\"& $DriveLatter)
                Sleep(200)
                $BackupIcon = @AppDataDir & "\YawStar\YawStar Drive Icon Changer\Icons\" & $DriveLatter & ".ico"
                RegWrite("HKEY_CURRENT_USER\Software\Classes\Applications\Explorer.exe\Drives\"& $DriveLatter & "\DefaultIcon", "", "REG_SZ", $IconPath)
                MsgBox(64, "Complete", "Drive Icon is successfully changed. Thank for using my program.", 10)
            EndIf
        Case $btnRestore
            $DriveLatter = GUICtrlRead($CboDLatter,0)
            RegDelete("HKEY_CURRENT_USER\Software\Classes\Applications\Explorer.exe\Drives\"& $DriveLatter)
            MsgBox(64, "Complete", "Drive Icon is now default Icon. Thank for using my program.", 10)
        Case $btnAbout
            _AboutGUI()
    EndSwitch
WEnd


Func _AboutGUI()
    GUISetState(@SW_DISABLE)
    Local $Aboutdlg = GUICreate("About", 302, 195, -1, -1, $WS_SYSMENU, $WS_EX_TOPMOST)
    GUISetBkColor(0xFFFFFF)
    FileInstall("Resources\Icons\AboutIcon.ico", @AppDataDir & "\YawStar\YawStar Drive Icon Changer\Icons\AbutIcon.ico")
    FileInstall("Resources\Images\YawStar.jpg", @AppDataDir & "\YawStar\YawStar Drive Icon Changer\Images\YawStar.jpg")
    GUISetIcon(@AppDataDir & "\YawStar\YawStar Drive Icon Changer\Icons\AbutIcon.ico")
    $PicYawStar = GUICtrlCreatePic(@AppDataDir & "\YawStar\YawStar Drive Icon Changer\Images\YawStar.jpg", 8, 3, 55, 55)
    $Label2 = GUICtrlCreateLabel("YawStar Drive Icon Changer", 70, 8, 255, 23)
    GUICtrlSetFont(-1, 12, 800, 0, "Leelawadee")
    $Label3 = GUICtrlCreateLabel("YawStar Corporation  Â©2008", 152, 144, 145, 18)
    GUICtrlSetFont(-1, 8, 400, 0, "Leelawadee")
    $Label1 = GUICtrlCreateLabel("Version 1.0", 116, 32, 69, 19)
    GUICtrlSetFont(-1, 10, 400, 0, "Leelawadee")
    $Label6 = GUICtrlCreateLabel("Thank you for using my software. Send E-mail", 49, 96, 206, 18)
    GUICtrlSetFont(-1, 8, 400, 0, "Leelawadee")
    $Label7 = GUICtrlCreateLabel("to yawhackka@gmail.com if you have any suggestion.", 49, 108, 208, 26)
    GUICtrlSetFont(-1, 8, 400, 0, "Leelawadee")
    GUISetState(@SW_SHOW)

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                Local $Aboutdlg

                WinActivate("YawStar Drive Icon Changer")
                GUIDelete($Aboutdlg)
                GUISetState(@SW_ENABLE)
                ExitLoop
        EndSwitch
    WEnd
EndFunc   ;==>_AboutGUI

 

Edited by Jos
Put code in codebox
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...