AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Programmieren allgemein Executeandwait nimmt keinen Doppelpunkt als Parameter
Thema durchsuchen
Ansicht
Themen-Optionen

Executeandwait nimmt keinen Doppelpunkt als Parameter

Ein Thema von antonymaier · begonnen am 2. Mai 2017 · letzter Beitrag vom 3. Mai 2017
Antwort Antwort
nahpets
(Gast)

n/a Beiträge
 
#1

AW: Executeandwait nimmt keinen Doppelpunkt als Parameter

  Alt 2. Mai 2017, 11:06
Was kommt dabei heraus, wenn Du hieraus 'c:\plink.exe -N -R 1234:localhost:1234 user@server.com -P 22' ExtractFilePath machst?

Du übergibts der Funktion keinen gültigen Dateinamen, wie soll sie da ein vernünftiges Ergebnis liefern. Sie muss an den Doppelpunkten scheitern.

Ändere Deine Funktion bitte ab, ungefähr sowas:
Delphi-Quellcode:
Function ExecuteAndWait(sExecutableFile : String; sParameter : String; wWindowState : Word = SW_SHOWNORMAL) : Boolean;
var
siInfo : TStartUpInfo;
piInfo : TProcessInformation;
begin
    FillChar(siInfo, SizeOf(siInfo), #0);
    with siInfo do begin
    cb := SizeOf(siInfo);
    dwFlags := STARTF_USESHOWWINDOW;
    wShowWindow := wWindowState;
    end;
    Result := CreateProcess(NIL, pChar(sExecutableFile + ' ' + sParameter), NIL, NIL, FALSE, CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS, NIL, pchar(ExtractFilePath(sExecutableFile)),siInfo, piInfo);
end;
Aufruf ungefähr so:
Delphi-Quellcode:
if ExecuteAndWait('c:\plink.exe', '-N -R 1234:localhost:1234 user@server.com -P 22',SW_SHOWNORMAL) then begin
  // irgendwas;
end else begin
  // irgendwas anderes;
end;
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 14:46 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz