我想在这段代码里加上出指定盘符,要怎么弄?
#NoTrayIcon
dim const $Version = "XX网吧虚拟盘连接器"
If WinExists($Version) Then
MsgBox(4096+16,"警告","程序已在运行,请不要重复执行!!!",5)
Exit
Else
AutoItWinSetTitle($Version)
EndIf
Dim $check3 = 0, $Progress = 0, $x = 0, $check = 0, $dir = "254"
$go = "E:\NBMSClient\BarClientView.exe" ;此处添加你成功出盘后要运行的程序
checkdisk()
If $check = 1 Then
Run($go)
Exit
EndIf
net()
ProgressOn("", "", "","-1","-1",1)
$thread = DllCallbackRegister("thread", "int", "hwnd;int;int;dword")
$thread_call = DllCall("user32.dll", "int", "SetTimer", "hwnd", 0, "int", 0, "int", 100, "ptr", DllCallbackGetPtr($thread))
$thread1 = DllCallbackRegister("thread", "int", "hwnd;int;int;dword")
$thread1_call = DllCall("user32.dll", "int", "SetTimer", "hwnd", 0, "int", 0, "int", 500, "ptr", DllCallbackGetPtr($thread1))
While 1
_ReduceMemory()
$msg = GUIGetMsg()
WEnd
Func thread($hWnd, $uiMsg, $idEvent, $dwTime)
If $idEvent = $thread_call[0] Then
jd()
EndIf
If $idEvent = $thread1_call[0] Then
If $check = 0 Then
check()
Else
DllCall("user32.dll", "int", "KillTimer", "hwnd", 0, "int", $thread1_call)
DllCallbackFree($thread1)
EndIf
EndIf
EndFunc
Func jd()
$Progress += 1
ProgressSet($Progress, " 游戏磁盘加载中,请稍等......")
If $check = 1 Then
DllCall("user32.dll", "int", "KillTimer", "hwnd", 0, "int", $thread_call)
DllCallbackFree($thread)
ProgressSet(100, " 游戏磁盘加载成功,即将运行游戏......")
Sleep(800) ;此处延时是为了有足够的时间显示进度条上加载成功的提示
Run($go)
ProgressOff()
Exit
EndIf
If $Progress = 100 Then
$x += 1
If $x > 2 Then ;重试两次失败后退出
ProgressOff()
DllCall("user32.dll", "int", "KillTimer", "hwnd", 0, "int", $thread_call)
DllCallbackFree($thread)
MsgBox(16,"提示","游戏盘加载超时,未能正常出盘,请与工作人员联系",10)
Exit
Else
If $check <> 1 Then
$Progress = 0
ProgressSet($Progress, " 第" & $x & "次重试,请稍等......")
Sleep(800) ;此处延时是为了有足够的时间显示第几次重试
net()
EndIf
EndIf
EndIf
EndFunc
Func check()
If $check = 1 Then Return $check
$check3 += 1
$var = DriveGetDrive( "all" )
If $check3 > $var[0] Then $check3 = 0
If NOT @error Then
If FileExists($var[$check3] & "\" & $dir) Then
$check = 1
Return $check
EndIf
EndIf
EndFunc
Func checkdisk()
$dir = "LanDiskTest" ;判断目录,建议写个较深的路径或较偏的目录
$var = DriveGetDrive( "all" )
If NOT @error Then
For $i = 1 to $var[0]
If FileExists($var[$i] & "\" & $dir) Then
$check = 1
Return $check
EndIf
Next
EndIf
EndFunc
Func net()
If Ping("192.168.1.253", 150)Then
ShellExecuteWait("iscsicli"," AddTargetPortal 192.168.1.253 3260","","",@SW_HIDE)
ShellExecute("iscsicli"," LoginTarget iqn.2003-12.com.netzonesoft:landisk-VER5 T * * * * * * * * * * * * * * * 0","","",@SW_HIDE)
Else
ProgressOff()
MsgBox(16,"错误","游戏服务器出现故障,部分游戏不可运行,请联系网管!!!")
Exit
EndIf
EndFunc
Func _ReduceMemory($i_PID = -1)
If $i_PID <> -1 Then
Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID)
Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0])
DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0])
Else
Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
EndIf
Return $ai_Return[0]
EndFunc;==> _ReduceMemory() |