找回密码
 加入
搜索
查看: 1774|回复: 6

请高手帮我在下面这段代码里加上出指定盘符的代码,我自已加不上

[复制链接]
发表于 2009-7-6 13:27:32 | 显示全部楼层 |阅读模式
我想在这段代码里加上出指定盘符,要怎么弄?
#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()
发表于 2009-7-6 14:35:35 | 显示全部楼层
不是很明白你问什么?
 楼主| 发表于 2009-7-6 14:45:52 | 显示全部楼层
让下面这个代码在上面代码运行完之后运行要怎么加?
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[511]")
    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
 楼主| 发表于 2009-7-6 17:00:42 | 显示全部楼层
顶一下,急用。。。。。。。。。。
发表于 2009-7-6 19:16:27 | 显示全部楼层
本帖最后由 lynfr8 于 2009-7-6 19:18 编辑

很长的代码
没有实际环境理解不了作者思路
让下面这个代码在上面代码运行完之后运行要怎么加?

从逻辑上应该放在死循环之前
MyChangeVolume("F:","H:")
While 1
        $msg = GUIGetMsg()
WEnd

一般这种系统环境不是人人都有的完整代码
还是建议自己多摸索自行解决
因为没有测试环境而且问题描述不清晰
很难给解决方法的
 楼主| 发表于 2009-7-6 20:47:06 | 显示全部楼层
这两段代码都是论坛上的,就是要在连上虚拟盘之后,把盘符改为H盘,并打开指定程序,如果能做到检测磁盘里特定的文件夹或文件,就把有那个文件夹或文件的驱动器盘符改为自已指定的就好了.
发表于 2009-7-6 20:53:07 | 显示全部楼层
.......就算你这样说也没法帮你啊。。。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-23 01:22 , Processed in 0.078860 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表