Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


WriteFile to a Pipe...

I get (with getlasterror())"GetProcessId failed with error 536: Waiting for a process to open the other end of the pipe." with the following code:

Shouldn't I be able to write to the pipes buffer even if another process hasn't connected to the pipe?


void ErrorExit(LPTSTR lpszFunction);

int main(int argc, char **argv)

const int BUFSIZE = 1024;
const int OUTBUFSIZE = 10000;
const int PIPE_TIMEOUT = 10000;

char szPipeName[] = "\\.\pipe\myLog";

char pBuf[]="Does this work?";
DWORD cbToWrite = sizeof(pBuf);
DWORD cbWritten;
BOOL bRetConn = FALSE;
BOOL bRetWrite = FALSE;

HANDLE hPipe = CreateNamedPipe(szPipeName, // pipe name
PIPE_ACCESS_OUTBOUND, // read/write access
(PIPE_TYPE_BYTE | // message type pipe
PIPE_READMODE_BYTE | // message-read mode
PIPE_NOWAIT), // blocking mode PIPE_WAIT
OUTBUFSIZE, // output buffer size
BUFSIZE, // input buffer size
PIPE_TIMEOUT, // client time-out
NULL); // no security attribute

bRetWrite = WriteFile(hPipe, // handle to pipe
pBuf, // buffer to write from
cbToWrite, // number of bytes to write
&cbWritten, // number of bytes written
NULL); // Pointer to Overlapped struct

return 0;


Sign In or Register to comment.