|
|
|
|
|
Dicas
|
|
Visual Basic (Windows)
|
|
|
Título da Dica: Monitorar uma aplicação Win32 e aguardar até que seja finalizada.
|
|
|
|
Postada em 11/2/2004 por PC
Private Declare Function OpenProcess Lib "Kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long Private Declare Function GetExitCodeProcess Lib "Kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long Private Declare Sub Sleep Lib "Kernel32" (ByVal dwMilliseconds As Long) Const STILL_ACTIVE = &H103 Const PROCESS_QUERY_INFORMATION = &H400 'esta função só termina quando o comando q vc deu for fechado, exemplo 'vc mandou abrir o notepad, enquanto ele estiver aberto a função não para Sub Shell32Bit(ByVal SuaTarefa As String) Dim hProcess As Long Dim RetVal As Long hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False, Shell(SuaTarefa, 1))
Do GetExitCodeProcess hProcess, RetVal DoEvents: Sleep 100 Loop While RetVal = STILL_ACTIVE End Sub
Private Sub Form_Load() 'abre o notepad (bem fácil :-P Shell32Bit "Notepad"
' só depois de vc fechar o notepad ;-) MsgBox "Notepad fechou" End Sub
|
|
|
|
|