AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Externes Programm starten

Ein Thema von Willie1 · begonnen am 5. Jan 2016 · letzter Beitrag vom 8. Jan 2016
 
Willie1

Registriert seit: 28. Mai 2008
691 Beiträge
 
Delphi 10.1 Berlin Starter
 
#1

Externes Programm starten

  Alt 5. Jan 2016, 16:00
Hallo Delphifreunde/nnen,
ich benutze diese Routine, um ein externes Programm zu starten
Delphi-Quellcode:
function TMainForm.ExecAndWait(const CommandLine, Parameter: string) : Boolean;
var
  StartupInfo: Windows.TStartupInfo; // start-up info passed to process
  ProcessInfo: Windows.TProcessInformation; // info about the process
  ProcessExitCode: Windows.DWord; // process's exit code
begin
  // Set default error result
  Result := False;
  // Initialise startup info structure to 0, and record length
  FillChar(StartupInfo, SizeOf(StartupInfo), 0);
  StartupInfo.cb := SizeOf(StartupInfo);
  StartupInfo.dwFlags := STARTF_USESHOWWINDOW;
  StartupInfo.wShowWindow:=SW_HIDE;
  // Execute application commandline
  if Windows.CreateProcess(nil,
                           PChar(CommandLine),
                           nil,
                           nil,
                           False,
                           0,
                           nil,
                           PChar(Parameter),
                           StartupInfo,
                           ProcessInfo) then
  begin
    try
      // Now wait for application to complete
      if Windows.WaitForSingleObject(ProcessInfo.hProcess, INFINITE)
        = WAIT_OBJECT_0 then
        // It's completed - get its exit code
        if Windows.GetExitCodeProcess(ProcessInfo.hProcess,
          ProcessExitCode) then
          // Check exit code is zero => successful completion
          if ProcessExitCode = 0 then
            Result := True
    finally
      // Tidy up
      Windows.CloseHandle(ProcessInfo.hProcess);
      Windows.CloseHandle(ProcessInfo.hThread);
    end
  end
  else
    Showmessage(Format('Fehler:%d - %s!',[GetLastError,SysErrorMessage(GetLastError)]))
end; {TMainForm.ExecAndWait} //stammt aus Delphipraxis
Unter Vista 32-Bit klappt das Starten von Windows-Paint prima unter Windows 10-64-Bit stürzt das gesammte Programm total ab. Als Hobby-Programmierer fehlen mir Grundlagen. Kann ein 64-Bit Programm (Windows-Paint ist doch 64-Bit?) aus einem 32-Bit Programm überhaupt starten? Wenn ja, wie? Durch meine Augenerkrankung ist die Suche im Web für mich sehr schwierig, deshalb wende ich mich direkt an euch.
Danke für eure Hilfe
Willie.
  Mit Zitat antworten Zitat
 

 

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 18:15 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