Hallo,
eine einfache Lösung wäre z.B. mit
CreateProcess.
Hier ein Beispiel:
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42:
| function ExecAndWait(const FileName: string; const CmdShow: Integer): Longword; var zAppName: array[0..512] of Char; zCurDir: array[0..255] of Char; WorkDir: string; StartupInfo: TStartupInfo; ProcessInfo: TProcessInformation; AppIsRunning: DWORD; begin StrPCopy(zAppName, FileName); GetDir(0, WorkDir); StrPCopy(zCurDir, WorkDir); FillChar(StartupInfo, SizeOf(StartupInfo), #0); StartupInfo.cb := SizeOf(StartupInfo); StartupInfo.dwFlags := STARTF_USESHOWWINDOW; StartupInfo.wShowWindow := CmdShow; if not CreateProcess(nil, zAppName, nil, nil, False, CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS, nil, nil, StartupInfo, ProcessInfo) then Result := WAIT_FAILED else begin while WaitForSingleObject(ProcessInfo.hProcess, 0) = WAIT_TIMEOUT do begin Application.ProcessMessages; Sleep(50); end;
WaitForSingleObject(ProcessInfo.hProcess, INFINITE); GetExitCodeProcess(ProcessInfo.hProcess, Result); CloseHandle(ProcessInfo.hProcess); CloseHandle(ProcessInfo.hThread); end; end; |
Es wird solange gewartet, bis Du die entsprechende Anwendung wieder schließt.
... oder einfach hier im Forum nach
CreateProcess suchen. ShellExecute sollte man zum Starten von exe-Dateien eigentlich nicht verwenden, auch wenn es funktioniert.
Eine weitere Möglichkeit wäre über eine Art Plugin System mit DLL's.
Hier mal ein Beispiel, wie man Formulare in DLL's nutzt.
www.michael-puff.de/...pets/FormInDLL.shtml
Letzteres hab ich selbst jedoch noch nie ausprobiert.