Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1049035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:33:09+00:00 2026-05-16T16:33:09+00:00

I have created a NamedPipe inside a Windows Service and starting the Service Manually

  • 0

I have created a NamedPipe inside a Windows Service and starting the Service Manually or as the System Starts up.

EDIT:

lpszPipename = TEXT("\\\\.\\pipe\\1stPipe"); 
OVERLAPPED m_OverLaped;
HANDLE hEvent;

hPipe=CreateNamedPipe (lpszPipename,
                       PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,
                       PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_NOWAIT,
                       PIPE_UNLIMITED_INSTANCES,BUFSIZE,
                       BUFSIZE,0,NULL);   

m_OverLaped.hEvent=CreateEvent(NULL,TRUE,TRUE,NULL);
m_OverLaped.Internal=0;
m_OverLaped.InternalHigh=0;
m_OverLaped.Offset=0;
m_OverLaped.OffsetHigh=0;

ConnectNamedPipe(hPipe,&m_OverLaped);

Now I want to Access the Named Pipe, Write some Message and Response back.

LPTSTR lpszPipename = TEXT("\\\\.\\pipe\\1stPipe"); 

OVERLAPPED m_OverLaped;
m_OverLaped.hEvent=CreateEvent(NULL,TRUE,TRUE,NULL);
m_OverLaped.Internal=0;
m_OverLaped.InternalHigh=0;
m_OverLaped.Offset=0;
m_OverLaped.OffsetHigh=0;

hPipe=CreateFile (lpszPipename,            // Gets the Pipename
                  GENERIC_READ | GENERIC_WRITE,// Client only writes to this pipe.
                  0,                       // Do not share this pipe with others.
                  NULL,                    // Do not inherit security.
                  OPEN_EXISTING,           // Pipe must exist.
                  FILE_ATTRIBUTE_NORMAL,   // I have no special requirements on
                                           //file attributes
                  NULL);  

dwMode = PIPE_READMODE_MESSAGE;

fSuccess = SetNamedPipeHandleState (hPipe,    // pipe handle 
                                    &dwMode,  // new pipe mode 
                                    NULL,     // don't set maximum bytes 
                                    NULL);    // don't set maximum time 
fSuccess = TransactNamedPipe (hPipe,                  // pipe handle 
                              lpszWrite,              // message to server
                              (lstrlen(lpszWrite)+1)*sizeof(TCHAR),//message length 
                              chReadBuf,              // buffer to receive reply
                              BUFSIZE*sizeof(TCHAR),  // size of read buffer
                              &cbRead,                // bytes read
                              &m_OverLaped); 
fSuccess = ReadFile (hPipe,                 // pipe handle 
                     chReadBuf,             // buffer to receive reply 
                     BUFSIZE*sizeof(TCHAR), // size of buffer 
                     &cbRead,               // number of bytes read 
                     &m_OverLaped);         // overlapped 

I have ommited the Error Checking Codes to be make it readable here. I get stuck for long(infinite may be ) time while executing TransactNamedPipe. I must be setting some parameters wrong , but I have tried the options as specified at MSDN.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T16:33:09+00:00Added an answer on May 16, 2026 at 4:33 pm
    m_OverLaped.hEvent = CreateEvent(NULL,TRUE,FALSE,NULL);
    ...
    ConnectNamedPipe(hPipe, &m_OverLaped);
    

    Since the pipe is created with FILE_FLAG_OVERLAPPED flag, you must pass LPOVERLAPPED parameter to every pipe I/O call (including TransactNamedPipe). If function returns FALSE and GetLastError returns ERROR_IO_PENDING, wait for m_OverLaped.hEvent – when it is set, operation is completed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a windows service which is creating a Named Pipe in it's service
I am creating a named pipe in windows service running on local system account
I have created a windows service which allows communications via namedpipes. This code worked
I have created a windows service which is set to start automatically. This service
I have created a PHP-script to update a web server that is live inside
I have created a program that write video stream to a named pipe on
I have created a c# windows application and written 75% of the code. The
I have created a Git repository on my Desktop machine (Windows 7) with: git
i have created a running process which listens for input: listen = Popen([home/user/listen], stdout=PIPE,
I have created infopath form library in SharePoint sever2010. I am using Windows server

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.