Advertisement

02.26.2007 at 02:10PM PST, ID: 22414640
[x]
Attachment Details

Named Pipes from a console application

Asked by concept99 in Delphi Programming Language, Delphi Programming

Tags: named, pipes, console

I am attempting to use rllibby's "Pipes" component in a console application. Everything works great when I create a VCL "client" app and a VCL "server" app. The 2 apps are quite simple, and simply send messages back and forth from exe to exe.

I attempted to rewrite the VCL client app as a console application and am now stuck. The code appears to me to be essentially the same, and when I step through with the debugger I see that the client is connecting and it is supposedly writing to the pipe (true is returned). However, nothing ever shows up in my server VCL app. But, if I launch the client VCL version and send a message, everything is great. Here is the code I am using in my console application. The pipe is named "myNamedPipe", and the VCL server app is launched first and actually activates the pipe before I run the client:

/////////////////////////////////////////////////////////////////////////////////////
//start of code
program CmdClient;

{$APPTYPE CONSOLE}

uses
  SysUtils,
  Pipes;

var
  wideChars   : array[0..255] of WideChar;
  myString    : String;
  bSuccess01, bSuccess02     : Boolean;
  iLength : integer;
  PipeClient1 : TPipeClient;
begin

  PipeClient1 := TPipeClient.Create(nil);
  try
    begin
      with PipeClient1 do
        begin
          Name := 'myNamedPipe';
          PipeName := 'myNamedPipe';
          ServerName := '.';
          //OnPipeMessage := PipeClient1PipeMessage;
        end;

      myString := 'the message I am sending';
      iLength := Length(myString)+1;

      StringToWideChar(myString,
        wideChars,
        iLength);

      bSuccess01 := PipeClient1.Connect(5000);
      WriteLn('Success: ' + BoolToStr(bSuccess01));

      bSuccess02 := PipeClient1.Write(wideChars,iLength*2);
      WriteLn('s2: ' + BoolToStr(bSuccess02));
    end;
  finally
    FreeAndNil(PipeClient1);
  end;
 
end.
// end of code
////////////////////////////////////////////////////////////////////////////////////

This is a bit outside the scope of the original question, but I'll ask anyway. I'd also like to be able to use the OnPipeMessage event in my console application, but I haven't found a way to do it from a console app. Is it possible to use this event from a console application?

RegardsStart Free Trial
 
Loading Advertisement...
 
[+][-]02.26.2007 at 04:11PM PST, ID: 18613734

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.26.2007 at 04:30PM PST, ID: 18613837

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.26.2007 at 08:27PM PST, ID: 18614691

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.27.2007 at 08:07AM PST, ID: 18617965

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.27.2007 at 09:19AM PST, ID: 18618666

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.28.2007 at 08:27AM PST, ID: 18626359

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.28.2007 at 10:02AM PST, ID: 18627194

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Delphi Programming Language, Delphi Programming
Tags: named, pipes, console
Sign Up Now!
Solution Provided By: rllibby
Participating Experts: 1
Solution Grade: A
 
 
[+][-]02.28.2007 at 10:16AM PST, ID: 18627285

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32