ERFORDERLICHE
OBJEKTE
1 Commandbutton (Command1)
FORM-CODE
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 Function CloseHandle Lib "kernel32" _
(ByVal hObject As Long) As Long
Sub Command1_Click()
ShellAndWait "notepad.exe"
MsgBox "Notepad wurde beendet !", vbInformation
End Sub
Private Sub ShellAndWait(Befehl As String)
Dim hProcess As Long
Dim ProcessId As Long
Dim exitCode As Long
ProcessId = Shell(Befehl, 1)
hProcess = OpenProcess(&H400, False, ProcessId)
Do
Call GetExitCodeProcess(hProcess, exitCode)
DoEvents
Loop While exitCode = &H103&
Call CloseHandle(hProcess)
End Sub
Private Sub Form_Load()
Command1.Caption = "Notepad starten..."
End Sub
|