Страница: 1 |
|
Вопрос: Задержка.
|
Добавлено: 30.03.09 14:32
|
|
Автор вопроса: Sergey
|
Подскажите, как в VB6 сделать задержку?
Например, пока выполняется команда Shell.
Ответить
|
Номер ответа: 9 Автор ответа: Arseny
ICQ: 298826769
Вопросов: 53 Ответов: 1732
|
Профиль | | #9
|
Добавлено: 31.03.09 16:41
|
Есть вот такой модуль в коллекции:
- Option Explicit
- Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As VbAppWinStyle) As Long
- Public NoZaderjka As Boolean
-
- Private Declare Function CreateProcess Lib "kernel32" _
- Alias "CreateProcessA" _
- (ByVal lpApplicationName As String, _
- ByVal lpCommandLine As String, _
- lpProcessAttributes As Any, _
- lpThreadAttributes As Any, _
- ByVal bInheritHandles As Long, _
- ByVal dwCreationFlags As Long, _
- lpEnvironment As Any, _
- ByVal lpCurrentDriectory As String, _
- lpStartupInfo As STARTUPINFO, _
- lpProcessInformation As PROCESS_INFORMATION) As Long
-
- Private Declare Function CloseHandle Lib "kernel32" _
- (ByVal hObject As Long) As Long
-
- Private Declare Function MsgWaitForMultipleObjects Lib "user32" _
- (ByVal nCount As Long, _
- pHandles As Long, _
- ByVal fWaitAll As Long, _
- ByVal dwMilliseconds As Long, _
- ByVal dwWakeMask As Long) As Long
-
- Private Declare Function GetExitCodeProcess Lib "kernel32" _
- (ByVal hProcess As Long, _
- lpExitCode As Long) As Long
-
- Private Type STARTUPINFO
- cb As Long
- lpReserved As String
- lpDesktop As String
- lpTitle As String
- dwX As Long
- dwY As Long
- dwXSize As Long
- dwYSize As Long
- dwXCountChars As Long
- dwYCountChars As Long
- dwFillAttribute As Long
- dwFlags As Long
- wShowWindow As Integer
- cbReserved2 As Integer
- lpReserved2 As Long
- hStdInput As Long
- hStdOutput As Long
- hStdError As Long
- End Type
-
- Private Type PROCESS_INFORMATION
- hProcess As Long
- hThread As Long
- dwProcessId As Long
- dwThreadId As Long
- End Type
-
- Private Const QS_ALLINPUT = &HFF&
- Public Const QS_KEY = &H1
- Public Const QS_MOUSEBUTTON = &H4
- Public Const QS_MOUSEMOVE = &H2
- Public Const QS_PAINT = &H20
- Public Const QS_POSTMESSAGE = &H8
- Public Const QS_SENDMESSAGE = &H40
- Public Const QS_TIMER = &H10
- Public Const QS_MOUSE = (QS_MOUSEMOVE Or QS_MOUSEBUTTON)
- Public Const QS_INPUT = (QS_MOUSE Or QS_KEY)
-
- Private Const INFINITE = &HFFFFFFFF
-
- Private Const WAIT_OBJECT_0 = 0
-
- Public Function RunAndWait( _
- ByVal Application As String, _
- ByVal Arguments As String, _
- ByVal Directory As String, _
- ByRef RetCode As Long) As Boolean
- Dim si As STARTUPINFO
- Dim pi As PROCESS_INFORMATION
-
- If CreateProcess(Application, Arguments, ByVal 0&, ByVal 0&, _
- False, 0, ByVal 0&, Directory, si, pi) _
- Then
-
- If NoZaderjka = False Then
- Do
- If MsgWaitForMultipleObjects(1, pi.hProcess, 0, _
- INFINITE, QS_ALLINPUT) = WAIT_OBJECT_0 _
- Then
- Exit Do
- Else
- DoEvents
- End If
- Loop
- End If
-
- GetExitCodeProcess pi.hProcess, RetCode
- RunAndWait = True
-
- End If
-
- CloseHandle pi.hThread
- CloseHandle pi.hProcess
- End Function
-
Ответить
|
Страница: 1 |
Поиск по форуму