Gabs schon unter DOS

Hi VB’ler

Habe da so ein VB Programm, das eine Funktion aufrufen soll. Diese möchte ich als eigenständiges Programm ausführen, daß dann ( sobald es gestartet wird ) auf eine Default-Datei zugreift, und diese bearbeitet. Zum Schluß wird die Kontrolle wieder an das aufrufende Programm übergeben.
Ich wäre nicht überrascht, wenn das geht, aber wie ? Kann vielleicht jemand die wichtigen Schlüsselwörter in ein paar Zeilen hineinzaubern ?
Was sagt das aufrufende Programm ?
Wie verabschiedet sich das aufgerufene Programm ?

Vielen Dank für die Mühe, die ich euch mache …

Uwe P.

Hi,

ein Beispiel dafür wäre:

—Anfang—
Private 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 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 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 Byte
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 Function ShellGetHandle(ByVal sDateiname As String, lHandle As Long) As Boolean
Dim udtProcessInfo As PROCESS_INFORMATION
Dim udtStartupInfo As STARTUPINFO
Dim lSuccess As Long

udtStartupInfo.cb = Len(udtStartupInfo)
lSuccess = CreateProcess(0&, sDateiname, 0&, 0&, 1&, &H20, 0&, 0&, udtStartupInfo, udtProcessInfo)
If lSuccess = 1 Then
lHandle = udtProcessInfo.hProcess
ShellGetHandle = False
Else
ShellGetHandle = True
End If
End Function

Public Function Wait(ByVal lHandle As Long) As Boolean
If WaitForSingleObject(lHandle, 0) 0 Then
Wait = True
Else
Wait = False
End If
End Function
Syntax :
ShellGetHandle [Programm, Handle]

Beispiel :

Dim lHandle As Long
Dim bError As Boolean

bError = ShellGetHandle(„Notepad.exe“, lHandle)

If bError Then
MsgBox „Fehler! Programm kann nicht gestartet werden“
Else
MsgBox „Programm ist gestartet, jetzt wird gewartet“
Do While Wait(lHandle)
DoEvents 'Damit das VB Programm nicht „einfriert“
Loop
MsgBox „Programm wurde beendet“
End If