Thema: FreePascal Pipe in 64Bit Dll

Einzelnen Beitrag anzeigen

Gruber_Hans_12345

Registriert seit: 14. Aug 2004
1.426 Beiträge
 
Delphi 2007 Professional
 
#1

Pipe in 64Bit Dll

  Alt 7. Jan 2019, 14:46
Hallo ich verwende Lazarus um eine 64Bit DLL zu schreiben die eine Verbindung zu einer NamedPipe macht, Daten schreibt und liest, allerdings will das ganze nicht so recht.

Der vereinfachte Code :

Delphi-Quellcode:
   pipeName := '\\.\pipe\Client'#0;
   sendData := 'Test'#13#10#0;
   timeOut   := GetTickCount+5000;
   hPipe := CreateFile(PChar(pipeName), GENERIC_READ or GENERIC_WRITE, 0, nil, OPEN_EXISTING, 0, 0);
   writeln('hPipe : '+IntToStr(integer(hPipe))+' ('+IntToStr(GetLastError)+')');
   if (hPipe <> THandle(-1)) then begin
      dwMode := PIPE_READMODE_MESSAGE;
      res := SetNamedPipeHandleState(hPipe, @dwMode, nil, nil);
      writeln('SetNamedPipeHandleState : : '+IntToStr(integer(res))+' ('+IntToStr(GetLastError)+')');

      res := WriteFile(hPipe, sendData[1], length(sendData), readBytes, nil);
      writeln('WriteFile : : '+IntToStr(integer(res))+' ('+IntToStr(GetLastError)+')');

      readBytes := 0;

      while (readBytes = 0) and (GetTickCount < timeOut) do begin
         res   := PeekNamedPipe(hPipe, @Buffer[1], length(Buffer), @readBytes, @BytesAvail, @BytesLeft);
         writeln('PeekNamedPipe : : '+IntToStr(integer(res))+' ('+IntToStr(GetLastError)+') --- '+IntToStr(readBytes)+', '+IntToStr(BytesAvail)+', '+IntToStr(BytesLeft));
         if (readBytes = 0) then sleep(100);
      end;
      CloseHandle(hPipe);
   end;
Der Rückgabewert ist nun folgendes

Code:
07.01.2019 15:17:17> hPipe : 4792  (0)
07.01.2019 15:17:17> SetNamedPipe : : 1  (183)
07.01.2019 15:17:17> WriteFile : : 1  (183) 43  written : 43
07.01.2019 15:17:17> PeekNamedPipe : : 1  (183) --- 0, 0, 0
07.01.2019 15:17:17> PeekNamedPipe : : 1  (183) --- 0, 0, 0
07.01.2019 15:17:17> PeekNamedPipe : : 1  (183) --- 0, 0, 0
07.01.2019 15:17:18> PeekNamedPipe : : 1  (183) --- 0, 0, 0
Und das wundert mich ... der CreateFile funktioniert ohne Probleme, und liefert einen Handle, die folgenden Funktionen liefern zwar einen Result von <> 0 aber das GetLastError ist 183 kann mir wer sagen warum das der Fall sein könnte?
Gruss Hans

2B or not 2B, that is FF
  Mit Zitat antworten Zitat