Hallo Plasma,
Lordchen hat nicht unrecht, mit Hilfe der DLL geht dies auch. Aber wenn du nur diese Funktion brauchst, ist der Overhead zu groß.
Hier hilft dir das API:
Kopiere u.a. Code in ein Modul. Mit der Übergabe des gesamten Pfades an die Funktion ExecCmd wird die fremde Anwendung gestartet. Der Programmcode wird erst nach Beendigung der fremden Anwendung weiter ausgeführt.
Gruß JSD
Public Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessID As Long
dwThreadID As Long
End Type
Public 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
Public Const NORMAL_PRIORITY_CLASS = &H20&
Public Const INFINITE = -1&
Public Const STARTF_USESHOWWINDOW = &H1
Public Declare Function WaitForSingleObject Lib "kernel32" (ByVal _
hHandle As Long, ByVal dwMilliseconds As Long) As Long
Public 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
Public Declare Function CloseHandle Lib "kernel32" _
(ByVal hObject As Long) As Long
Public Declare Function GetExitCodeProcess Lib "kernel32" _
(ByVal hProcess As Long, lpExitCode As Long) As Long
'*******************************************
'Funktion zum Starten eines Prozesses
'*******************************************
Public Function ExecCmd(strAppName As String)
Dim proc As PROCESS_INFORMATION
Dim start As STARTUPINFO
Dim lngRet As Long
start.cb = Len(start)
start.dwFlags = STARTF_USESHOWWINDOW
start.wShowWindow = 3 'maximierte Fensterdarstellung
lngRet = CreateProcessA(0&, strAppName, 0&, 0&, 1&, NORMAL_PRIORITY_CLASS, _
0&, 0&, start, proc)
lngRet = WaitForSingleObject(proc.hProcess, INFINITE)
GetExitCodeProcess proc.hProcess, lngRet
CloseHandle proc.hThread
CloseHandle proc.hProcess
ExecCmd = lngRet
End Function |