AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Programmieren allgemein CreateProcess wirft Kernelbase Error
Thema durchsuchen
Ansicht
Themen-Optionen

CreateProcess wirft Kernelbase Error

Ein Thema von venice2 · begonnen am 2. Apr 2021 · letzter Beitrag vom 4. Apr 2021
 
venice2
(Gast)

n/a Beiträge
 
#7

AW: CreateProcess wirft Kernelbase Error

  Alt 2. Apr 2021, 15:40
Ich hatte oben noch bissl was geändert. pps:

Vorallem siehe "Tipp"
Habe ich

Delphi-Quellcode:
function PipeExec(CommandLine, Path: String; EnvironementStrings: PChar; var StdIO: TStdIO; UserToken: THandle; ShowWindow: DWORD = SW_HIDE): TProcessInformation;
const
  ProcessCreationFlags: DWord = NORMAL_PRIORITY_CLASS;
var
  SI : TStartupInfo;
  PathPChar : PChar;
begin
  // initialize the structure we are going to use
  Zeromemory(@SI, SizeOf(SI));
  Zeromemory(@result, SizeOf(result));
  // Fill the necessary fields
  SI.cb := sizeof(SI); // Size of the structure. The OS uses that to validat it
  SI.dwFlags := STARTF_USESHOWWINDOW   or // Use the wShowWindow field
                 STARTF_USESTDHANDLES; // use the handles we created for the std IO pipes
  SI.wShowWindow := ShowWindow; // Show the console or not...
  SI.hStdError := StdIO.stdError.hWrite; // Write errors to the error pipe
  SI.hStdInput := StdIO.stdIn.hRead; // read input from input pipe
  SI.hStdOutput := StdIO.stdOut.hWrite; // Write Ouput to output pipe

  if length(path) > 0 then
     PathPChar := PChar(Path)
  else
      PathPChar := nil;

  UniqueString(CommandLine); //<<<<<<< Hier!

  if UserToken = 0 then
  begin
    if not CreateProcess( nil, // must be NIL for win16 apps under NT, including DOS progs
                   pchar(CommandLine),
                   nil, // Process security attibutes. Sue same as current
                   nil, // Thread security attibutes. Sue same as current
                   true, // Inherite handles. Must be true for IO redirection
                   ProcessCreationFlags, // creation flags
                   EnvironementStrings, // If using with a CGI aplication, you MUST pass the HTTP headers as env. strings in this variable
                   PathPChar, // Directory of the new process
                   SI, // SISTEMINFO Structure used to initialize the new process
                   result) // PROCESINFORMATION structure used to control the newly created process
    then
      RaiseLastOSError;
  end
  else
  begin
    if not CreateProcessAsUser( UserToken, // UserToken of desired user. That token must be retreived with LogonUser or DuplicatteToken from a Impersonation token
                         nil, // must be NIL for win16 apps under NT, including DOS progs
                         pchar(CommandLine),
                         nil, // Process security attibutes. Sue same as current
                         nil, // Thread security attibutes. Sue same as current
                         true, // Inherite handles. Must be true for IO redirection
                         ProcessCreationFlags, // creation flags
                         EnvironementStrings, // If using with a CGI aplication, you MUST pass the HTTP headers as env. strings in this variable
                         PathPChar, // Directory of the new process
                         SI, // SISTEMINFO Structure used to initialize the new process
                         result) // PROCESINFORMATION structure used to control the newly created process
    then
      RaiseLastOSError;
  end;
end;
  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 15:48 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