可以来信索要;
[email protected]
[email protected]
解决方案 »
- VB如何下载有密码的FTP服务器上的文件(密码已知)
- VB调用C语言的dll,怎么调用返回字符数组的函数?
- 请问谁有DX7.0或8.0 FOR VB的下载连接
- 请教各位高手,如何编程序,在vb程序运行的时候,将DataGrid控件中的数据导入到excel中去?
- Win2000环境下,VB程序如何能得到计算机当前的CPU使用率?
- getchunk!!
- 如何使用byte()数组接收base64解码后的(图片)数据,请大神指教啊.
- spirit00的软件。下载吧!!下载并提出宝贵意见者给大分!!
- 罗玉胜你出来
- 有哪位老兄知道系统分析员、质量管理员、程序员等的岗位责任啊?
- 大家好,在win98下有PWS,在NT,2000Server下有IIS,在win2000 professional下用什么?
- 关于DATAGRID于数据绊定控件的联系
我已给你发信,我急需,请速回,谢谢!
SS = TIMER
DO
doevents
if timer - ss > 2
EXIT LOOP
end if
LOOP
你这个方法虽然可以,但CPU的使用率太高,我多次使用该延时,请问还有没有更好的方法?
我想让它延时什么也不干,就想在Unix中的 Sleep 一样!
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Declare Function SleepEx Lib "kernel32" (ByVal dwMilliseconds As Long, ByVal bAlertable As Long) As Long用:Sleep 2000
或:Sleep 2000,false(不能被唤醒)
Sleep 2000,True(可被唤醒)
感谢sbnth(晓风残夜思春水)、Amoon(阿木) 。
我一直是用死循环的方式,也感觉CPU占用太多,但是问题没有解决。
再问一句:SLEEP(2000)后,需要唤醒吗?
....
Private Sub Inet1_StateChanged(ByVal State As Integer)
if State =icResponseCompleted then
...........End Sub
PauseTime = 1 ' 设置暂停时间。
Start = Timer ' 设置开始暂停的时刻。
Do While Timer < Start + PauseTime
DoEvents ' 将控制让给其他程序。
Loop
但这个太费CPU了,我看了上面兄弟讲的sleep可,机子在那时候什么事都做不了,有什么好办法呢,我只是让和程序在运行完一个过程时,暂停一下
有好办法告诉我
大家上面总共提了两中方法,其一,使用API函数中的 Sleep ;其二,使用一个循环。
不过使用Sleep 我的其他进程什么也不干了,我之所以延时就是为了等待其他进程运行完后再继续运行,虽然这个方法不费CPU,却不能解决这个问题。
使用循环,可以解决我的问题,但CPU的使用率在 90%±10%。我希望能一位高手来提供第三种解决方法!!!!!!!!
进程内执行shell的例子,只要把你要执行的命令当成DoExtComm函数的参数,vb会一直等到这个进程完了以后,才继续下一步的操作,希望对你有帮助。
Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
'新建一个进程
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
'关闭进程
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As LongPrivate Const CREATE_NEW_CONSOLE = &H10
Private Const Process_query_infomation = &H400
Private Const Still_Active = &H103'得到当前的操作系统信息
Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
End Type'得到当前window系统目录
Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As LongPublic Function DoExtComm(sCommString As String)
Dim nSysVer As Long
Dim osInfo As OSVERSIONINFO
Dim hProcess As Long
Dim lExitCode As Long
Dim sExecString As String
Dim sCurDir As String
Dim pidNotePad As Long
Dim REt As Long
Dim sCommPath As String
'Set the structure size
osInfo.dwOSVersionInfoSize = Len(osInfo)
'Get the Windows version
REt& = GetVersionEx(osInfo)
'Chack for errors
If REt& = 0 Then MsgBox "Error Getting Version Information"
nSysVer = osInfo.dwPlatformId
Dim Path As String, strSave As String
'Create a buffer string
strSave = String(200, Chr$(0))
'Get the windows directory and
Path = Left$(strSave, GetWindowsDirectory(strSave, Len(strSave)))
If Mid(Path, Len(Path), 1) <> "\" Then Path = Path & "\"
' sWinDir = Environ("windir")
sCommPath = Path
If nSysVer = 1 Then 'windows98
sExecString = sCommPath + "command.com /c " + sCommString
Else
sExecString = sCommString
End If
pidNotePad = Shell(sExecString, vbHide)
hProcess = OpenProcess(Process_query_infomation, True, pidNotePad)
Do
GetExitCodeProcess hProcess, lExitCode
DoEvents
Loop While lExitCode = Still_Active
CloseHandle (pidNotePad)End Function
' sWinDir = Environ("windir")
sCommPath = Path
If nSysVer = 1 Then 'windows98
sExecString = sCommPath + "command.com /c " + sCommString
Else
sExecString = sCommString
End If
pidNotePad = Shell(sExecString, vbHide)