找回密码
 加入
搜索
查看: 4229|回复: 15

ISCSI虚拟盘的连接器问题

[复制链接]
发表于 2009-2-26 15:26:14 | 显示全部楼层 |阅读模式
由于本人是刚刚接触,所以很多东西不完全,想让大家帮忙改一下,我写的这个进度条好像有问题,无论出没有出盘,他一定要走完进度条才调用后面的程序,不知道为什么。
Func Quit()
    GUISetState(@SW_HIDE)
    DllCall($dll, "int:cdecl", "DeInitDecoration")
    DllCall($dll, "int:cdecl", "RemoveSkin")
    DllClose($dll)
    ;DirRemove(@AppDataDir&"\skin",1)
    Exit
EndFunc

Func _SkinGUI($SkincrafterDll, $SkincrafterSkin, $Handle)
   $Dll = DllOpen($SkincrafterDll)
   DllCall($Dll, "int:cdecl", "InitLicenKeys", "wstr", "1", "wstr", "", "wstr", "1@1.com", "wstr", "1")
   DllCall($Dll, "int:cdecl", "InitDecoration", "int", 1)
   DllCall($Dll, "int:cdecl", "LoadSkinFromFile", "wstr", $SkincrafterSkin)
   DllCall($Dll, "int:cdecl", "DecorateAs", "int", $Handle, "int", 25)
   DllCall($Dll, "int:cdecl", "ApplySkin")
EndFunc      ;==_SkinGUI

dim const $Version = "ISCSI连接器"


If WinExists($Version) Then
MsgBox(4096+16,"警告","程序已在运行,请不要重复执行!!!",5)
Exit
Else
AutoItWinSetTitle($Version)
EndIf


if FileExists("h:\") then  ;如果h盘存在
   if FileExists("h:\pcgame") then  ;并且pcgame目录存在
   runwait("f:\xs\原调用.exe","") ;则运行EXE文件
   else
   Msgbox("64","翔宇网吧游戏菜单提示您","请将移动设备拔掉或手动移除,然后再次运行本程序,谢谢!")
   endif
   exit
else ;否则运行下面程序

If Ping("192.168.1.229")Then   
$n = 1
while $n
ProgressOn("", "", "","-1","-1",1)
For $i = 0 to 100 step 2
sleep(270)
ProgressSet( $i, "         游戏磁盘加载中,请稍等......")
runwait(@ComSpec & " /c " & 'iscsicli AddTargetPortal 192.168.1.229 3260',"", "@SW_HIDE")
runwait(@ComSpec & " /c " & 'iscsicli LoginTarget iqn.2005-09.com.istorage.iscsi:0 T * * * * * * * * * * * * * * * 0',"", "@SW_HIDE");连接ISCSI虚拟磁盘
Next
sleep(1000)
if FileExists("h:\") then ;每5.5秒监控一次,只要文件出现则关闭进条。跳出死循坏并执游戏文件。
sleep(1000)
   Runwait("f:\xs\原调用.exe","")
   ProgressOff()
   exitloop
  EndIf
if $n = 3 Then ;等时间为$n的值乘5.5秒,现在即等待出盘时间为25秒,每5秒检测一次,出盘后关闭进度条。并运行游戏。
   ProgressOff()
   MsgBox("","","操作超时,部分游戏不可运行,请联系网管!!!")
   runwait("f:\xs\原调用.exe","") ;则运行EXE文件
   ExitLoop
        EndIf
$n = $n + 1
WEnd
else
   MsgBox("","","游戏服务器出现故障,部分游戏不可运行,请联系网管!!!")
   runwait("f:\xs\原调用.exe","") ;则运行EXE文件
EndIf
Endif
exit
 楼主| 发表于 2009-2-26 23:44:20 | 显示全部楼层
麻烦有人指点一下吧,谢谢。。。
发表于 2009-2-27 03:47:30 | 显示全部楼层
由于你的代码不完整,所以按你的意思重写了一个,但磁盘的判断是基于路径,可能会不太准确,建议用WMI或API

#NoTrayIcon
Dim $Progress = 0 ,$x = 0

dim const $Version = "ISCSI连接器"


If WinExists($Version) Then
        MsgBox(4096+16,"警告","程序已在运行,请不要重复执行!!!",5)
        Exit
Else
        AutoItWinSetTitle($Version)
EndIf

net()

ProgressOn("", "", "","-1","-1",1)

While 1
        _ReduceMemory()
        $nMsg = GUIGetMsg()
        AdlibEnable("jd",10)
WEnd



Func check()
        $dir = "pcgame" ;判断目录,建议写个较深的路径或较偏的目录
        $var = DriveGetDrive( "all" )
        If NOT @error Then
                For $i = 1 to $var[0]
                        If FileExists($var[$i] & "\" & $dir) Then
                                Return True
                        EndIf
                Next
        EndIf
EndFunc

Func jd()
        If $Progress = 100 Then
                $x += 1
                If $x > 2 Then ;重试两次失败后退出
                        ProgressOff()
                        MsgBox(16,"提示","游戏盘加载超时,未能正常出盘,请与工作人员联系",10)
                        Exit
                Else
                        If check() <> True Then
                                $Progress = 0
                                ProgressSet($Progress, "           第" & $x & "次重试,请稍等......")
                                net()
                                Sleep(1000) ;此处延时是为了有足够的时间显示第几次重试
                        EndIf
                EndIf
        EndIf
        If check() = True Then
                ProgressSet(100, "     游戏磁盘加载成功,即将运行游戏......")
                
                ;Run("程序") ;在此已成功出盘,此处添加你要运行的程序
                
                Sleep(1000) ;此处延时是为了有足够的时间显示进度条上加载成功的提示
                ProgressOff()
                Exit
        EndIf
        sleep(270) ;(进度条时间) 此处延时会因环境不同而不同,请按需调整
        ProgressSet($Progress, "         游戏磁盘加载中,请稍等......")
        $Progress += 1
EndFunc

Func net()
        If Ping("192.168.1.229", 250)Then
                ShellExecuteWait("iscsicli"," AddTargetPortal 192.168.1.229 3260","","",@SW_HIDE)
                ShellExecute("iscsicli"," LoginTarget iqn.2005-09.com.istorage.iscsi:0 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()

如有问题,请在贴中再提出

[ 本帖最后由 ceoguang 于 2009-2-27 03:50 编辑 ]
 楼主| 发表于 2009-2-27 11:03:51 | 显示全部楼层
好的,谢谢ceoguang,我研究一下有不懂的在请教。
 楼主| 发表于 2009-2-27 11:48:03 | 显示全部楼层
有一个问题,就是在连接虚拟盘的时候,进度条是不会走动的。。。直到连上了然后提示成功。

不知道为什么。
发表于 2009-2-27 14:37:22 | 显示全部楼层
不会走动是指?
连1%都没动吗?还是到百分几的时候不动了然后突然到了100%?
btw:你出盘时间为几秒?
 楼主| 发表于 2009-2-27 20:54:02 | 显示全部楼层
就是进度条那个地方是白的,什么都没有。然后过了一下就提示连接成功了~

出盘比较慢啊。有的要12秒这样,快的也要7,8秒
 楼主| 发表于 2009-2-27 20:57:12 | 显示全部楼层




先是第一副图,然后就直接到第二副图了。没有进度条走动。。。一直是空白的。。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2009-2-28 14:00:42 | 显示全部楼层
不可能吧,你修改过代码?
发你修改后的上来看看.
 楼主| 发表于 2009-2-28 18:35:59 | 显示全部楼层
我没有修改过啊,就是用你写的就是这样,我也不知道什么啊,我原来的代码上的进度条到是可以动的。
发表于 2009-2-28 19:07:24 | 显示全部楼层
附件经多个系统及多种配置测试过,没有你所说的问题
要注意的是代码中
AdlibEnable("jd",10)
当中的调用时间只能在16以下,如果无法显示进度条,请将10更改为1试试

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
 楼主| 发表于 2009-3-1 12:29:53 | 显示全部楼层
改了,还是不出现。我没办法了,哎。

我也换了几种配制,几个系统,2003,XP都测试过了,都是一样,进度条不会走动。
发表于 2009-3-1 13:21:07 | 显示全部楼层
楼主QQ多少?
.......................
 楼主| 发表于 2009-3-2 00:14:24 | 显示全部楼层
我QQ566227,你可以加我,我远程给你看。。。谢谢了。
发表于 2009-3-2 05:57:45 | 显示全部楼层
试试这个

#NoTrayIcon
dim const $Version = "ISCSI连接器"


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 = "程序" ;此处添加你成功出盘后要运行的程序
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()
        $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.229", 150)Then
                ShellExecuteWait("iscsicli"," AddTargetPortal 192.168.1.229 3260","","",@SW_HIDE)
                ShellExecute("iscsicli"," LoginTarget iqn.2005-09.com.istorage.iscsi:0 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()
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-9-22 05:36 , Processed in 0.099180 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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