Hallo,
ich hab ein Windows-Programm geschrieben, dass eine Konsolenanwendung (openssl.exe) startet und Parameter übergiebt.
Die Konsole ansich bleibt dem Benutzer verborgen.
Allerdings will ich aus Debuggründen die Text-Ausgabe der openssl.exe in mein Programm umleiten - erstmal in ein Memo...
Aber wie?
Hier mal die Funktion, mit der ich programmintern die "DOS"-Konsolenanwendungen starte:
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 TFormGenerate.ExecAndWait_New(const FileName, Params: String): Integer; var w: Cardinal; ExecuteInfo: TSHELLEXECUTEINFO;
begin Result:= -1; FillChar(ExecuteInfo, SizeOf(TSHELLEXECUTEINFO), 0); With ExecuteInfo do begin cbSize:= SizeOf(TSHELLEXECUTEINFO); lpVerb:= 'open'; lpFile:= PChar(Filename); lpParameters := PChar(Params); nShow:= SW_HIDE; fMask:= SEE_MASK_NOCLOSEPROCESS or SEE_MASK_FLAG_NO_UI; Wnd:= Application.Handle; end; if ShellExecuteEx(@ExecuteInfo) and (ExecuteInfo.hInstApp> 32) then begin w:= WAIT_FAILED; If ExecuteInfo.hProcess <> 0 then Repeat w:= WaitForSingleObject(ExecuteInfo.hProcess, 1000); Application.ProcessMessages; Until (Abbruch= True) or (w= WAIT_OBJECT_0) or (w= WAIT_ABANDONED) or (w= WAIT_FAILED);
if (w<> WAIT_ABANDONED) and (w<> WAIT_FAILED) then Result:= 1 else Result:= 0; end else Case GetLastError of ERROR_FILE_NOT_FOUND, ERROR_PATH_NOT_FOUND: Result:= -2; ERROR_NO_ASSOCIATION: Result:= -3; end; end; |
Statt dem Application.Handle Da muss wohl ein
anderes Handle hin? Aber wie leite ich den Text aus diesem Handle dann in ein Memo (oder Stringlist) um?
Danke schon mal,
Frankie