#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <GuiTreeView.au3>
#include <StaticConstants.au3>
#include <TreeViewConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=c:\documents and settings\administrator\桌面\temp\image.kxf
$Form1_1 = GUICreate("Image Restore Tool", 743, 450, 197, 154)
$StatusBar1 = _GUICtrlStatusBar_Create($Form1_1)
_GUICtrlStatusBar_SetSimple($StatusBar1)
_GUICtrlStatusBar_SetText($StatusBar1, "Create By:Yuanyongping Create Date:2010/04/19 Version:V1.0")
$Label1 = GUICtrlCreateLabel(" Image Restore and Backup Tool For RSI-SH ", 0, 0, 743, 45)
GUICtrlSetFont(-1, 26, 400, 0, "Georgia")
GUICtrlSetColor(-1, 0x00FF00)
GUICtrlSetBkColor(-1, 0x008080)
$Group1 = GUICtrlCreateGroup("Storage Device Information", 10, 200, 529, 129)
GUICtrlSetFont(-1, 12, 400, 0, "Constantia")
GUICtrlSetColor(-1, 0x0000FF)
$Label2 = GUICtrlCreateLabel("本机硬盘:", 24, 225, 81, 20)
GUICtrlSetFont(-1, 12, 800, 0, "新宋体")
$Label3 = GUICtrlCreateLabel("恢复硬盘:", 24, 246, 81, 20)
GUICtrlSetFont(-1, 12, 800, 0, "新宋体")
$Label4 = GUICtrlCreateLabel("容量:", 286, 225, 47, 20)
GUICtrlSetFont(-1, 12, 800, 0, "新宋体")
$Label5 = GUICtrlCreateLabel("容量:", 286, 246, 47, 20)
GUICtrlSetFont(-1, 12, 800, 0, "新宋体")
$Label6 = GUICtrlCreateLabel("分区数:", 432, 226, 64, 20)
GUICtrlSetFont(-1, 12, 800, 0, "新宋体")
$Label7 = GUICtrlCreateLabel("分区数:", 433, 246, 64, 20)
GUICtrlSetFont(-1, 12, 800, 0, "新宋体")
$Label8 = GUICtrlCreateLabel("提示:", 24, 287, 47, 20)
GUICtrlSetFont(-1, 12, 800, 0, "新宋体")
GUICtrlSetColor(-1, 0xFF0000)
$Input1 = GUICtrlCreateInput("", 72, 281, 457, 27)
GUICtrlSetFont(-1, 14, 800, 0, "黑体")
GUICtrlSetColor(-1, 0xFF0000)
$L_hdd = GUICtrlCreateLabel("", 99, 220, 184, 27)
GUICtrlSetFont(-1, 14, 400, 0, "Segoe UI")
$D_HDD = GUICtrlCreateLabel("", 99, 240, 184, 27)
GUICtrlSetFont(-1, 14, 400, 0, "Segoe UI")
$D_HDD_SIZE = GUICtrlCreateLabel("", 329, 240, 94, 27)
GUICtrlSetFont(-1, 14, 400, 0, "Segoe UI")
$L_HDD_SIZE = GUICtrlCreateLabel("", 329, 220, 94, 27)
GUICtrlSetFont(-1, 14, 400, 0, "Segoe UI")
$D_HDD_PAR = GUICtrlCreateLabel("", 493, 240, 24, 27)
GUICtrlSetFont(-1, 14, 400, 0, "Segoe UI")
$L_HDD_PAR = GUICtrlCreateLabel("", 493, 220, 24, 27)
GUICtrlSetFont(-1, 14, 400, 0, "Segoe UI")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Note", 11, 48, 529, 137)
GUICtrlSetFont(-1, 12, 400, 0, "Segoe UI")
GUICtrlSetColor(-1, 0x0000FF)
$Label9 = GUICtrlCreateLabel("1.在镜像恢复前,请移除除需恢复硬盘外的其它存储设备.", 19, 72, 485, 27)
GUICtrlSetFont(-1, 14, 400, 0, "Constantia")
$Label10 = GUICtrlCreateLabel("2.若恢复硬盘有异响,请检查是否供电不足导致.", 19, 99, 438, 27)
GUICtrlSetFont(-1, 14, 400, 0, "Constantia")
$Label11 = GUICtrlCreateLabel("3.在镜像恢复期间请勿插入其它移动存储设备,否则会报错.", 21, 124, 508, 27)
GUICtrlSetFont(-1, 14, 400, 0, "Constantia")
$Label12 = GUICtrlCreateLabel("4.若发现"我的电脑"内盘符过多,请重启计算机.", 22, 149, 429, 27)
GUICtrlSetFont(-1, 14, 400, 0, "Constantia")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group3 = GUICtrlCreateGroup("Restore and Backup", 9, 343, 529, 81, -1, $WS_EX_TRANSPARENT)
GUICtrlSetFont(-1, 12, 400, 0, "Constantia")
GUICtrlSetColor(-1, 0x0000FF)
$Setting = GUICtrlCreateButton("Setting", 370, 367, 153, 41)
GUICtrlSetFont(-1, 14, 800, 0, "Comic Sans MS")
$Button1 = GUICtrlCreateButton("Restore", 22, 367, 153, 41)
GUICtrlSetFont(-1, 15, 800, 0, "Comic Sans MS")
$Button2 = GUICtrlCreateButton("Backup", 194, 367, 153, 41)
GUICtrlSetFont(-1, 14, 800, 0, "Comic Sans MS")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group4 = GUICtrlCreateGroup("Restore Option", 547, 46, 185, 377)
GUICtrlSetFont(-1, 11, 400, 0, "Segoe UI")
GUICtrlSetColor(-1, 0x0000FF)
$Combo1 = GUICtrlCreateCombo("Choose Model", 551, 72, 177, 25)
GUICtrlSetData(-1, "Toshiba|Sony|Benq|Viewsonic|Sharp|HP|Acer|NB5|Install System")
GUICtrlSetFont(-1, 14, 400, 0, "Segoe UI")
$List1 = GUICtrlCreateList("", 551, 108, 177, 306)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlSetCursor (-1, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
;判断GHOST程式是否存在
$cfg=@ScriptDir&"\config.ini"
If FileExists($cfg)= 0 Then
MsgBox(0+64,"Error","Config.ini配置文件丢失!")
Else
$Read_ghost=IniRead($cfg,"config","exe","")
If FileExists($Read_ghost)=0 Then
MsgBox(0+64,"Error","没有发现Ghost32.exe程式,请配置GHOST32程式路径")
Exit
EndIf
EndIf
AdlibRegister ("usb",1000)
IniWrite($cfg,"config","image","")
Global $read_combo,$read_list,$read_model,$yp,$np,$newprj,$prj_name,$read_prjname,$newname,$yname,$nname,$chgname
Global $var1,$iI,$var,$ii,$lb_project,$List1,$l_model,$l_project,$var2,$newname1,$del_prj,$rd_prjname,$savechg,$rd_prj
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $List1
If $read_combo <> "Choose Model" Then
$read_list=GUICtrlRead ($List1)
EndIf
If $read_combo <> "Choose Model" And $read_list <> "" Then
$read_model=IniRead($cfg,$read_combo,$read_list,"")
IniWrite ($cfg,"config","image",$read_model)
EndIf
Case $Combo1
Project()
Case $Button1
Restore()
Case $Setting
set()
EndSwitch
WEnd
Func usb()
$objWMIService = objget("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
$getdevice = $objWMIService.ExecQuery("Select * from Win32_DISKDRIVE")
$usbdev=0
For $object in $getdevice
If $object.interfaceType = "USB" Then
$usbdev=$usbdev+1
EndIf
If $usbdev > 1 Then MsgBox(0+64,"USB Test","System Detect two USB device!Pls Remove.")
Next
$objWMIService = objget("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
$getdevice = $objWMIService.ExecQuery("Select * from Win32_DISKDRIVE")
For $object in $getdevice
If $object.DeviceID = "\\.\PHYSICALDRIVE0" And $object.interfaceType = "IDE" Then
GUICtrlSetData($L_hdd,$object.Caption)
GUICtrlSetData($L_HDD_SIZE,Floor($object.size/1000/1000/1000)&" GB")
GUICtrlSetData($L_HDD_PAR,$object.Partitions)
EndIf
Next
$objWMIService = objget("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
$getdevice = $objWMIService.ExecQuery("Select * from Win32_DISKDRIVE")
For $object in $getdevice
If $object.DeviceID <> "\\.\PHYSICALDRIVE0" Then
GUICtrlSetData($d_hdd,$object.Caption)
GUICtrlSetData($d_HDD_SIZE,Floor($object.size/1000/1000/1000)&" GB")
GUICtrlSetData($d_HDD_PAR,$object.Partitions)
GUICtrlSetData($Input1,"请在右边窗口中选择对应机型进行恢复.")
ExitLoop
ElseIf $object.DeviceID = "\\.\PHYSICALDRIVE0" Then
GUICtrlSetData($Input1,"未检测到外置存储器,请插入要恢复的硬盘!")
EndIf
Next
EndFunc
Func Restore()
$read_input=GUICtrlRead($Input1)
If ProcessExists("ghost32.exe")=0 Then
If $read_model <> "" Then
GUICtrlSetData($Input1,"恢复系统进行中...")
Run ($Read_ghost&" "&"-clone"&","&"Mode=load"&","&"src="&$read_model&","&"dst=2"&"-fx -sure -nofile")
ElseIf StringInStr($read_input,"未")=0 Then
GUICtrlSetData($Input1,"请选择要恢复的镜像.")
ElseIf $read_model = "" Then
MsgBox(0,"路径出错","系统检测到所选机型镜像文件路径为空.")
EndIf
Else
MsgBox(0+64,"注意!","系统检测到已经有在运行Ghost32程式,"&@CRLF&"请先结束已运行的Ghost32.")
EndIf
EndFunc
Func Project()
$read_combo=GUICtrlRead ($Combo1)
If $read_combo = "Choose Model" Then GUICtrlSetData ($List1,"")
If $read_combo="sharp" Or $read_combo="benq" Or $read_combo="nb5" Or $read_combo="acer" Or $read_combo="Toshiba" Or $read_combo="hp" Or $read_combo="Viewsonic" Or $read_combo="Sony" Or $read_combo="Install system" Then
GUICtrlSetData($List1,"")
$var = IniReadSection("config.ini", $read_combo)
If @error Then
MsgBox(4096, "项目无机型", "系统检测到所选项目没有配置机型.")
Else
For $i = 1 To $var[0][0]
If $var[$i][0] <>"" Then
GUICtrlSetData ($List1,StringUpper($var[$i][0]))
EndIf
Next
EndIf
EndIf
EndFunc
Func set()
$Form2 = GUICreate("Restore and Backup Option", 481, 492, 192, 122)
$Restore = GUICtrlCreateGroup("Restore", 6, 16, 465, 113)
GUICtrlSetFont(-1, 11, 800, 0, "MS UI Gothic")
GUICtrlSetColor(-1, 0x0000FF)
$FX = GUICtrlCreateCheckbox("不出现提示", 16, 40, 97, 17)
$SURE = GUICtrlCreateCheckbox("确认所有询问", 16, 62, 105, 17)
$RB = GUICtrlCreateCheckbox("重启", 16, 85, 97, 17)
$quiet = GUICtrlCreateCheckbox("静默模式", 16, 107, 97, 17)
$nocrc = GUICtrlCreateCheckbox("忽略CRC校验错误", 128, 61, 137, 17)
$noask = GUICtrlCreateCheckbox("不询问分卷文件", 128, 39, 129, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$backup = GUICtrlCreateGroup("Backup", 6, 136, 465, 113)
GUICtrlSetFont(-1, 11, 800, 0, "MS UI Gothic")
GUICtrlSetColor(-1, 0x0000FF)
$split = GUICtrlCreateCheckbox("指定大小", 16, 160, 81, 17)
$autoname = GUICtrlCreateCheckbox("自动命名GHS", 16, 182, 113, 17)
$compress = GUICtrlCreateCheckbox("压缩模式", 16, 205, 97, 17)
$Compressrate = GUICtrlCreateCombo("Z1", 99, 159, 145, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$pm = GUICtrlCreateGroup("Project/Model", 5, 256, 465, 225)
GUICtrlSetFont(-1, 11, 800, 0, "MS UI Gothic")
GUICtrlSetColor(-1, 0x0000FF)
$l_Project = GUICtrlCreateList("", 10, 295, 121, 174)
$l_model = GUICtrlCreateList("", 240, 296, 121, 174)
$p_add = GUICtrlCreateButton("增加", 146, 319, 75, 33)
GUICtrlSetFont(-1, 12, 400, 0, "黑体")
$p_chg = GUICtrlCreateButton("重命名", 146, 362, 75, 33)
GUICtrlSetFont(-1, 12, 400, 0, "黑体")
$p_del = GUICtrlCreateButton("删除", 146, 406, 75, 33)
GUICtrlSetFont(-1, 12, 400, 0, "黑体")
$m_add = GUICtrlCreateButton("增加", 375, 319, 75, 33)
GUICtrlSetFont(-1, 12, 400, 0, "黑体")
$m_chg = GUICtrlCreateButton("重命名", 375, 362, 75, 33)
GUICtrlSetFont(-1, 12, 400, 0, "黑体")
$m_del = GUICtrlCreateButton("删除", 375, 406, 75, 33)
GUICtrlSetFont(-1, 12, 400, 0, "黑体")
$lb_project = GUICtrlCreateLabel("项目", 48, 274, 34, 18)
$lb_model = GUICtrlCreateLabel("机型", 286, 275, 34, 18)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$var1 = IniReadSectionNames("config.ini")
If @error Then
MsgBox(4096, "Config Error", "Config文件未配置.")
Else
For $ii = 1 To $var1[0]
GUICtrlSetData ($l_project,StringUpper($var1[$ii]))
Next
EndIf
While 1
$mMsg = GUIGetMsg()
Switch $mMsg
Case $GUI_EVENT_CLOSE
ExitLOOP
Case $p_add
add()
Case $p_chg
chg()
Case $l_project <> ""
ls_model()
Case $m_chg
Case $m_del
EndSwitch
WEnd
GUIDelete("from2")
EndFunc
Func chg()
$Form5 = GUICreate("Input New Project Name", 211, 104, 192, 124)
$rd_prjname=GUICtrlRead($l_project)
If $rd_prjname <> "" Or $rd_prjname="sharp" Or $rd_prjname="benq" Or $rd_prjname="nb5" Or $rd_prjname="acer" Or $rd_prjname="Toshiba" Or $rd_prjname="hp" Or $rd_prjname="Viewsonic" Or $rd_prjname="Sony" Or $rd_prjname="Install system" Then
$name = GUICtrlCreateLabel("Please Input New Name:", 8, 8, 181, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x808000)
$chgname = GUICtrlCreateInput("", 8, 40, 185, 21)
$yname = GUICtrlCreateButton("确定", 21, 72, 75, 25)
$nname = GUICtrlCreateButton("取消", 104, 72, 75, 25)
GUISetState(@SW_SHOW)
EndIf
While 1
$savechg=GUICtrlRead($chgname)
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
ExitLOOP
Case $yname
If $savechg<> "" Then
$a=IniRenameSection($cfg,$rd_prjname,$savechg,1)
ExitLOOP
If $a= 0 Then
MsgBox (0,"提示","该项目没有任何机型.")
EndIf
Else
MsgBox (0,"错误!","项目名称不能为空,请重新输入.")
EndIf
Case $nname
ExitLOOP
EndSwitch
WEnd
set()
GUIDelete ("from5")
EndFunc
Func add()
$Form3 = GUICreate("Input New Project", 211, 104, 192, 124)
$Label1 = GUICtrlCreateLabel("Please Input New Project:", 8, 8, 181, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x808000)
$newprj = GUICtrlCreateInput("", 8, 40, 185, 21)
$yp = GUICtrlCreateButton("确定", 21, 72, 75, 25)
$np = GUICtrlCreateButton("取消", 104, 72, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$rd_newprj=GUICtrlRead($newprj)
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
ExitLOOP
Case $yp
If $rd_newprj<> "" Then
IniWriteSection($cfg,$rd_newprj,"")
ExitLoop
Else
MsgBox (0,"错误提示!","新增项目名称不能为空!")
EndIf
Case $np
ExitLOOP
EndSwitch
WEnd
GUIDelete("form3")
SET()
EndFunc
Func ls_model()
$rd_prj=GUICtrlRead($l_project)
If $rd_prj<> "" Or $rd_prj="sharp" Or $rd_prj="benq" Or $rd_prj="nb5" Or $rd_prj="acer" Or $rd_prj="Toshiba" Or $rd_prj="hp" Or $rd_prj="Viewsonic" Or $rd_prj="Sony" Or $rd_prj="Install system" Then
GUICtrlSetData($l_model,"")
$var2 = IniReadSection("config.ini", $rd_prj)
If Not @error Then
If $var2 <> "" Then
For $iii = 1 To $var2[0][0]
If $var2[$iii][0] <>"" Then
GUICtrlSetData ($l_model,StringUpper($var2[$iii][0]))
EndIf
Next
EndIf
EndIf
EndIf
EndFunc