我的代码如下a2:
WinWnd = FindWindow(vbNullString, SysPath & "\cmd.exe")
If WinWnd = 0 Then
GoTo a1
Else
GoTo a2
End If
a1:主要是循环判断进程是否存在,如果存在就等待,如果不存在就执行,但是造成了在程序退出之前cpu永远都是100%
请教高手解决的办法
WinWnd = FindWindow(vbNullString, SysPath & "\cmd.exe")
If WinWnd = 0 Then
GoTo a1
Else
GoTo a2
End If
a1:主要是循环判断进程是否存在,如果存在就等待,如果不存在就执行,但是造成了在程序退出之前cpu永远都是100%
请教高手解决的办法
do
WinWnd = FindWindow(vbNullString,SysPath & "\cmd.exe")
if WinWnd = 0 then
exit do
else
sleep 1
doevents
end if
loop...
Do While WinWnd = FindWindow(vbNullString, SysPath & "\cmd.exe")
Sleeep 1
DoEvents
Loop
Do While FindWindow(vbNullString, SysPath & "\cmd.exe")
Sleep 1 '这是一个API函数,你自己加进去
DoEvents
Loop
a2:
WinWnd = FindWindow(vbNullString, SysPath & "\cmd.exe")
If WinWnd = 0 Then
GoTo a1
Else
GoTo a2
End If
a1: 把a1后的处理代码写成一个函数,就起名为a1吧!
在界面上放置一个timer控件,双击添加代码
WinWnd = FindWindow(vbNullString, SysPath & "\cmd.exe")
If WinWnd = 0 Then
a1
end if
private sub subSleep(byval lngD as long)
lngP=Gettickcount
do
DoEvents
loop until (GettickCount-lngP)>lngD
end sub
WinWnd=0
do
WinWnd=FindWindow(vbNullString,SysPath & "\cmd.exe")
call subSleep(1000) ’释放CPU资源1秒钟
loop until WinWnd>0