У меня такой вопрос:
Например есть программа, ее нужно запустить и дождатся завершения?
Как мне это сделать?
P.S. Пардон за баян ,но я даже не знаю кл.слова для поиска.
Sasha_karasov писал(а):но я даже не знаю кл.слова для поиска.
GSerg писал(а): Если тебе надо блокировать основной поток (с заморозкой интерфейса и неотвечанием программы), то используй WaitForSingleObject.
Sasha_karasov писал(а):Ну помогит блин ну строчно нужно! Вам 5 минут написать мне 2 чиса искать, вы люди ли нет?
Sasha_karasov писал(а):Ну помогит блин ну строчно нужно! Вам 5 минут написать мне 2 чиса искать, вы люди ли нет?
keks-n писал(а):Да в примере к Waiter'у ожидание завершения есть! Зачем "Поиск", зачем гайд?
Пасиба.Lumen писал(а):Используй WaitForSingleObject с параметром, по-моему, APP_INFINITE или что-то вроде этого. Сейчас не в том состоянии, чтобы вспомнить, клава двоится .Когда просохну от пьянки - вспомню.
Public Enum PriorityEnum
NORMAL_PRIORITY_CLASS = &H20
IDLE_PRIORITY_CLASS = &H40
HIGH_PRIORITY_CLASS = &H80
End Enum
Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
Private Declare Function SetPriorityClass Lib "kernel32" (ByVal hProcess As Long, ByVal dwPriorityClass As Long) As Long
Public Enum WindowStyle
SW_HIDE = 0
SW_NORMAL = 1
SW_MAXIMIZE = 3
SW_MINIMIZE = 6
End Enum
Private Declare Function CreateProcessA Lib "kernel32" (ByVal lpApplicationName As Long, ByVal lpCommandLine As String, ByVal lpProcessAttributes As Long, ByVal lpThreadAttributes As Long, ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, ByVal lpEnvironment As Long, ByVal lpCurrentDirectory As Long, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Const INFINITE = -1&
Private Const STARTF_USESHOWWINDOW = &H1
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
Public Enum VKeyEnum
VK_SHIFT = &H10
VK_CONTROL = &H11
VK_LSHIFT = &HA0
VK_RSHIFT = &HA1
VK_LCONTROL = &HA2
VK_RCONTROL = &HA3
End Enum
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private 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 Long) As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
'**********************************************************
' Âûïîëíåíèå êîììàíäíîé ñòðîêè
'----------------------------------------------------------
Public Function SystemExecute(ByRef CmdLine As String, Optional Show As WindowStyle = SW_NORMAL) As Long
Dim proc As PROCESS_INFORMATION
Dim start As STARTUPINFO
Dim Res As Long
' Initialize the STARTUPINFO structure:
start.cb = Len(start)
start.dwFlags = STARTF_USESHOWWINDOW
start.wShowWindow = Show
' Start the shelled application:
Res = CreateProcessA(0&, CmdLine$, 0&, 0&, 1&, NORMAL_PRIORITY_CLASS, 0&, 0&, start, proc)
' Wait for the shelled application to finish:
Res = WaitForSingleObject(proc.hProcess, INFINITE)
Call GetExitCodeProcess(proc.hProcess, Res)
Call CloseHandle(proc.hThread)
Call CloseHandle(proc.hProcess)
SystemExecute = Res
End Function
Private Sub Form_Load()
SystemExecute "notepad.exe"
MsgBox "CLOSE
End Sub
Сейчас этот форум просматривают: AhrefsBot и гости: 180