请高手帮我在下面这段代码里加上出指定盘符的代码,我自已加不上
我想在这段代码里加上出指定盘符,要怎么弄?#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 Then
jd()
EndIf
If $idEvent = $thread1_call 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 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
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)
DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle)
Else
Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
EndIf
Return $ai_Return
EndFunc;==> _ReduceMemory() 不是很明白你问什么? 让下面这个代码在上面代码运行完之后运行要怎么加?
MyChangeVolume("F:","H:")
Func MyChangeVolume($Old,$New)
Local $Struct,$VolumeName
If StringRight($Old,1)<>"\" Then $Old&="\"
If StringRight($New,1)<>"\" Then $New&="\"
If Not FileExists($Old) Then Return -1
If FileExists($New) Then Return -1
$Struct = DllStructCreate ("char")
DllCall("kernel32.dll", "int", "GetVolumeNameForVolumeMountPoint", "str", $Old, "ptr", DllStructGetPtr($Struct), "dword",511)
$VolumeName=DllStructGetData($Struct,1)
DllCall("kernel32.dll", "int", "DeleteVolumeMountPointW", "wstr",$Old)
DllCall("kernel32.dll", "int", "SetVolumeMountPointW", "wstr", $New, "wstr",$VolumeName)
EndFunc 顶一下,急用。。。。。。。。。。 本帖最后由 lynfr8 于 2009-7-6 19:18 编辑
很长的代码
没有实际环境理解不了作者思路
让下面这个代码在上面代码运行完之后运行要怎么加?
从逻辑上应该放在死循环之前MyChangeVolume("F:","H:")
While 1
$msg = GUIGetMsg()
WEnd
一般这种系统环境不是人人都有的完整代码
还是建议自己多摸索自行解决
因为没有测试环境而且问题描述不清晰
很难给解决方法的 这两段代码都是论坛上的,就是要在连上虚拟盘之后,把盘符改为H盘,并打开指定程序,如果能做到检测磁盘里特定的文件夹或文件,就把有那个文件夹或文件的驱动器盘符改为自已指定的就好了. .......就算你这样说也没法帮你啊。。。
页:
[1]