AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Programmieren allgemein E2033 Die Typen der tatsächlichen und formalen Var-Parameter müssen übereinstimmen
Thema durchsuchen
Ansicht
Themen-Optionen

E2033 Die Typen der tatsächlichen und formalen Var-Parameter müssen übereinstimmen

Ein Thema von wschrabi · begonnen am 6. Feb 2025 · letzter Beitrag vom 6. Feb 2025
 
wschrabi

Registriert seit: 16. Jan 2005
456 Beiträge
 
#1

E2033 Die Typen der tatsächlichen und formalen Var-Parameter müssen übereinstimmen

  Alt 6. Feb 2025, 10:22
Hallo,
Ich Bekomme

[dcc64 Fehler] MainUnitv2k.pas(25328): E2033 Die Typen der tatsächlichen und formalen Var-Parameter müssen übereinstimmen

  Result := CreatePipe(ReadPipe, WritePipe, @SecurityAttr, 0); Ich weiß nicht Weiter.
Hier mein Code.
Wäre um jede HIlfe Dankbar.
WS


Delphi-Quellcode:
function CreateInheritablePipe(var ReadPipe, WritePipe: THandle): Boolean;
var
  SecurityAttr: TSecurityAttributes;
begin
  FillChar(SecurityAttr, SizeOf(TSecurityAttributes), 0);
  SecurityAttr.nLength := SizeOf(TSecurityAttributes);
  SecurityAttr.bInheritHandle := True;
  SecurityAttr.lpSecurityDescriptor := nil;

  Result := CreatePipe(ReadPipe, WritePipe, @SecurityAttr, 0);
end;

function Tform1.fnExecuteWSLCommand(const Command: string): string;
var
  StartupInfo: TStartupInfo;
  ProcessInfo: TProcessInformation;
  SecurityAttr: TSecurityAttributes;
  myReadPipe, myWritePipe: THandle;
  Buffer: array[0..255] of AnsiChar;
  BytesRead: DWORD;
  Output: TStringList;
begin
  Result := '';
  FillChar(StartupInfo, SizeOf(TStartupInfo), 0);
  FillChar(ProcessInfo, SizeOf(TProcessInformation), 0);
  FillChar(SecurityAttr, SizeOf(TSecurityAttributes), 0);

   SecurityAttr.nLength := SizeOf(TSecurityAttributes);
   SecurityAttr.bInheritHandle := True;
   SecurityAttr.lpSecurityDescriptor := nil;

  (*
  SecurityAttr.nLength := SizeOf(TSecurityAttributes);
  SecurityAttr.bInheritHandle := True;
  *)

  // Create pipes for capturing output
   if not CreateInheritablePipe(myReadPipe, myWritePipe) then
        RaiseLastOSError;

  try
    StartupInfo.cb := SizeOf(TStartupInfo);
    StartupInfo.dwFlags := STARTF_USESTDHANDLES or STARTF_USESHOWWINDOW;
    StartupInfo.hStdOutput := MyWritePipe;
    StartupInfo.hStdError := MyWritePipe;
    StartupInfo.wShowWindow := SW_HIDE;

    // Prepare the WSL command
    if not CreateProcess(
      nil,
      PChar('C:\Windows\System32\wsl.exe ' + Command),
      nil,
      nil,
      True,
      CREATE_NO_WINDOW,
      nil,
      nil,
      StartupInfo,
      ProcessInfo) then
    begin
      RaiseLastOSError;
    end;

    CloseHandle(MyWritePipe); // Close the write end of the pipe

    Output := TStringList.Create;
    try
      repeat
        BytesRead := 0;
        if ReadFile(MyReadPipe, Buffer, SizeOf(Buffer) - 1, BytesRead, nil) and (BytesRead > 0) then
        begin
          Buffer[BytesRead] := #0; // Null-terminate the buffer
          Output.Add(string(Buffer));
        end;
      until BytesRead = 0;

      Result := Output.Text; // Combine all output lines into a single string
    finally
      Output.Free;
    end;

    // Wait for the process to finish and clean up
    WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
    CloseHandle(ProcessInfo.hProcess);
    CloseHandle(ProcessInfo.hThread);
    
  finally
    CloseHandle(MyReadPipe); // Close the read end of the pipe
  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 05:27 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 by Thomas Breitkreuz