Article View: borland.public.delphi.nativeapi
Article #12091Re: Named pipes
From: Mikael Lenfors
Date: Mon, 25 Nov 2002 16:01
Date: Mon, 25 Nov 2002 16:01
86 lines
2883 bytes
2883 bytes
Thanks, the Win32 Help file was what I needed to get started.
The application I'm connecting to is the WinSock server so I don't have to
use CreateNamedPipe, instead I just do a CreateFile to connect to the
existing pipe. Then I use WriteFile to write to the file. The problem is it
doesn't work! Either CreateFile or WriteFile reports any errors but the
NamedPipes server does not receive anything!
Any ideas?
Regards, Mikael
unit NamedPipeUnit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
Var OutFile: HFile;
Buffer: Array [1..100] Of Char;
S: String;
Written: DWord;
I: Integer;
Overlapped: TOverlapped;
begin
FillChar(OVerlapped, SizeOf(Overlapped), 0);
OutFile := CreateFile(PChar('\\10.1.1.246\PIPE\MW32PMOBC2S'), // The name
of the pipe
Generic_Read + Generic_Write,
File_Share_Read + File_Share_Write,
Nil,
Open_Existing,
File_Attribute_Normal,
0);
If OutFile = INVALID_HANDLE_VALUE Then
Begin
ShowMessage('No out-pipe available');
End
Else
Begin
S := 'My message';
For I := 1 To Length(S) Do
Buffer[I] := S[I];
If Not WriteFile(OutFile, Buffer, Length(S), Written, @Overlapped)
Then
Begin
ShowMessage('Write command failed');
End;
CloseHandle(OutFile);
End; // OutFile opened
End;
End.
Technical Details
Message-ID:
<3de24961@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-04!supernews.com!news.maxwell.syr.edu!newsfeed1.cidera.com!Cidera!news.uni-x.net!newsgroups.borland.com!not-for-mailReferences:
<3de1cde4$1@newsgroups.borland.com> <3de1dc6a$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f94dd,50f4414abd1cb831 X-Google-Attributes: gidf94dd,public X-Google-ArrivalTime: 2002-11-25 08:18:02 PST From: "Mikael Lenfors" <mikael@lenfors.se> Newsgroups: borland.public.delphi.nativeapi References: <3de1cde4$1@newsgroups.borland.com> <3de1dc6a$1@newsgroups.borland.com> Subject: Re: Named pipes Date: Mon, 25 Nov 2002 17:01:37 +0100 Lines: 91 Organization: Lenfors Data AB X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 NNTP-Posting-Host: 194.52.95.3 Message-ID: <3de24961@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1038240097 194.52.95.3 (25 Nov 2002 08:01:37 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-04!supernews.com!news.maxwell.syr.edu!newsfeed1.cidera.com!Cidera!news.uni-x.net!newsgroups.borland.com!not-for-mail