Как отследить завершение скрытой программы? - VB

Узнай цену своей работы

Формулировка задачи:

Na http://www.relib.com/topic.asp?id=704977&tp=1 estj primer, kak atsleditj zavershenie programmi, kotoraja sapushchena iz prilozhenija, i kotoraja vidna. Mozhno li zdelatj toze samoe, no chtob' prilozhenjie bilo HIDE. Tjipa abc=shell('asda.exe.', vbHide)

Решение задачи: «Как отследить завершение скрытой программы?»

textual
Листинг программы
Const NORMAL_PRIORITY_CLASS = &H20&
Const STARTF_USESHOWWINDOW = &H1
Const SW_HIDE = 0
 
Type PROCESS_INFORMATION
  hProcess As Long
  hThread As Long
  dwProcessId As Long
  dwThreadId As Long
End Type
 
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
 
Declare Function CreateProcess Lib 'kernel32' Alias 'CreateProcessA' (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 lpCurrentDriectory As Long,
lpStartupInfo As STARTUPINFO,        lpProcessInformation As PROCESS_INFORMATION) As Long
 
Declare Function WaitForSingleObject Lib 'kernel32' (ByVal Handle As Long,        ByVal dwMilliseconds As Long) As Long
 
Declare Function CloseHandle Lib 'kernel32' (ByVal hObject As Long) As Long
 
Sum RunExtApp()
Dim Proc As PROCESS_INFORMATION
Dim Start As STARTUPINFO
Dim f
 
Start.dwFlags = STARTF_USESHOWWINDOW
Start.wShowWindow = SW_HIDE ' ВОТ ТО ЧТО ТЕБЕ НАДО
Start.cb = Len(Start)
 
v = CreateProcess(0,'c: est.exe',0, 0, True, NORMAL_PRIORITY_CLASS, 0, 0, Start, Proc)
 
If v <> 0 Then
v = CloseHandle(Proc.hThread)
 
do while WaitForSingleObject(Proc.hProcess, 0) = 258
loop
 
v = CloseHandle(Proc.hProcess)
end if
 
End Sub

ИИ поможет Вам:


  • решить любую задачу по программированию
  • объяснить код
  • расставить комментарии в коде
  • и т.д
Попробуйте бесплатно

Оцени полезность:

11   голосов , оценка 3.909 из 5
Похожие ответы