Func _SetMYJX()
Local $noide, $nousb, $no1394, $rb, $hfp, $hfpf1, $arr, $num, $str, $chen
$chen=IniRead("onekey.ini","data","search","2")
If @error Then
MsgBox(0,"警告","按默认只搜索2层目录")
$chen=2
EndIf
$Drive = DriveGetDrive("FIXED")
For $i = 1 To $Drive[0]
_filelist($Drive[$i])
Next
$MForm1 = GUICreate("还原镜像", 322, 315, -1, -1, BitOR($WS_SYSMENU, $WS_CAPTION, $WS_BORDER), 0, $XForm1)
$MGroup1 = GUICtrlCreateGroup("镜像", 8, 8, 305, 153)
$filelj = GUICtrlCreateCombo("搜索。", 24, 32, 217, 21)
GUICtrlSetData(-1, stringtrimright($str, 1) ,'')
$filelj = GUICtrlCreateInput("请输入或选择镜像文件", 24, 51, 217, 21)
$MButton1 = GUICtrlCreateButton("打 开", 248, 51, 51, 21)
GUICtrlCreateLabel("请点击 <打开> 镜像文件:", 24, 32, 200, 17)
GUICtrlCreateLabel("镜像恢复到分区:", 24, 84, 100, 17)
$var2 = DriveGetDrive("FIXED")
If Not @error Then
For $i = 1 To $var2[0]
$hfp3 = $var2[$i] & "|"
$hfp = $hfp & $hfp3
$hfp1 = $var2[1]
Next
EndIf
$MCombo1 = GUICtrlCreateCombo("", 128, 80, 113, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL, $CBS_UPPERCASE))
GUICtrlSetData(-1, $hfp, $hfp1)
$MButton2 = GUICtrlCreateButton("还原", 62, 283, 75, 25)
$MButton3 = GUICtrlCreateButton("关闭", 190, 283, 75, 25)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE, $MButton3
GUIDelete($MForm1)
Return 0
Case $MButton1
$drivedbs = ""
$jxfile = FileOpenDialog("选择镜像文件", "d:", "(*.gho;*.ghs)|所有文件(*.*)", 1 + 2, "", $XForm1)
If Not @error Then
FileDelete(@ScriptDir & "\ghostr.bat")
$PFPD = StringUpper(StringLeft($jxfile, 3))
If DriveGetType($PFPD) <> "Fixed" Then
MsgBox(4096, "错误", "只支持硬盘恢复。")
GUICtrlSetData($filelj, "", "")
ContinueLoop
EndIf
GUICtrlSetData($filelj, $jxfile, "")
EndIf
Case $MButton2
$jxfile = GUICtrlRead($filelj)
FileDelete(@ScriptDir & "\ghostr.bat")
$PFPD = StringUpper(StringLeft($jxfile, 3))
If DriveGetType($PFPD) <> "Fixed" Then
MsgBox(4096, "错误", "目前只支持硬盘恢复。
ContinueLoop
EndIf
GUICtrlSetData($filelj, $jxfile, "")
$hfpf = GUICtrlRead($MCombo1) & ""
$pd1 = 1
$pd2 = 1
$drivedb = StringSplit(StringUpper($disbk), "|")
For $i = 1 To $drivedb[0]
If $pd1 = 1 Then
If $drivedb[$i] = $PFPD Then
$drivedbs = $drivedb[$i + 1]
$pd1 = 0
EndIf
EndIf
If $pd2 = 1 Then
If $drivedb[$i] = $hfpf Then
$hfpf1 = $drivedb[$i + 1]
$pd2 = 0
EndIf
EndIf
If $pd1 = 0 And $pd2 = 0 Then ExitLoop
Next
If $drivedbs = $hfpf1 Then
MsgBox(16 + 4096, "错误", "备份文件与恢复盘不能是同一分区。", 0, $MForm1)
ContinueLoop
EndIf
FileWrite(@ScriptDir & "\ghostr.bat", "ghost -clone,mode=pload,src=" & $drivedbs & StringTrimLeft($jxfile, 2) & ":1,dst=" & $hfpf1 & " -sure")
_SetQJ()
Shutdown(6)
EndSwitch
WEnd
EndFunc ;==>_SetMYJX
Func _filelist($searchdir)
$search = FileFindFirstFile($searchdir & "\*.*") ;;;;查指定目录下的文件
If $search = -1 Then Return -1 ;;;;如果找不到,返回值 -1
While 1
$file = FileFindNextFile($search) ;;;查找下一个文件
If @error Then ;;;如果找不到文件
FileClose($search) ;;;则关闭此句柄
Return ;;;返回
ElseIf $file = "." Or $file = ".." Then ;;如果找到的文件名为.或..则ContinueLoop
ContinueLoop ;;;在某些版本的AU3里面可以不需要上行和这行。
ElseIf StringInStr(FileGetAttrib($searchdir & "" & $file), "D") Then;;如果找到的是一个文件夹,则
$arr = StringRegExp($searchdir & "" & $file, '\\', 3)
$num = UBound($arr)
If $num < $chen Then
_filelist($searchdir & "" & $file) ;;递归调用filelist函数,并传参数 "$searchdir & "" & $file"
EndIf
EndIf ;;;$file为查找到的文件夹名称,上一行意思就是进入此文件夹继续查找文件.如此循环
If StringInStr($file, '.gho') Then $str &= $searchdir & "" & $file & @CRLF;_ArrayAdd($filelist,$searchdir & "" & $file );MsgBox( 0,0,$searchdir & "" & $file & @crlf )
WEnd
EndFunc ;==>_filelist
尝试这样写也不行。。