Re: SetNamedPipeHandleState problems??

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



OK. Problem is you need a handle to a pipe, not a file. Yes, the doc states that it can be
used with a handle returned by CreateFile, but that's only because CreateFile can be used to
get a handle to the client end of a named pipe. Pipe != File.

Perhaps you should state what it is you're *actually* trying to accomplish? Or read more
about named (or anonymous) pipes. Or files.

--
Tom

"FredsFriend" <FredsFriend@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:73E41AF8-7F39-4760-82E1-98EE20DB51FF@xxxxxxxxxxxxxxxx
> Ahhh maby I didn't make my self clear.
> This is all on the local machine.
>
> There is no server.
> Concidently the WaitNamedPipe function didn't do much.
>
> heres an updated version of the source code which still doesn't work.
> Note: this is the entire source there is no server.
>
> I have put comments in in places which I thought there may be problems
> stating the values of variables at different stages in running the
> application.
> Try compiling it and see if you get the same results that I have put in the
> comments.
>
>
> #include <windows.h>
>
>
> int WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
> int nShowCmd )
> {
> SECURITY_ATTRIBUTES attr;
> attr.lpSecurityDescriptor = NULL;
> attr.bInheritHandle = TRUE;
>
> DWORD lastError = GetLastError();
>
> // this is ok because I havn't made any calls yet
> // lastError = 6 = ERROR_INVALID_HANDLE
>
> HANDLE fileHandle = CreateFile( "TempFile.log", GENERIC_READ |
> GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
> &attr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
>
> lastError = GetLastError();
>
> // lastError = 183L = ERROR_ALREADY_EXISTS
>
> DWORD pipeState = PIPE_NOWAIT;
> SetNamedPipeHandleState( fileHandle, &pipeState, NULL, NULL );
>
> lastError = GetLastError();
>
> // lastError = 87L = ERROR_INVALID_PARAMETER
>
> CloseHandle( fileHandle );
>
> }
>
>
> Thanks


.



Relevant Pages

  • Problem with pipes
    ... I have a server end of a pipe which is in message type and non- ... blocking mode with Max instanceset as one. ... by calling ConnectNamedPipe() then checking whether GetLastError() ...
    (microsoft.public.vc.language)
  • Re: How long do named pipes linger
    ... did a call to GetLastError() and checked if the culprit showed up, ... I just tried again with a new pipe. ... > I've spent quite a bit of time in Windows Internals, my own library, ...
    (microsoft.public.development.device.drivers)
  • Re: How long do named pipes linger
    ... Well, as I guessed from the observed failures, and as I subsequently tried, I ... did a call to GetLastError() and checked if the culprit showed up, ... I just tried again with a new pipe. ...
    (microsoft.public.development.device.drivers)
  • Re: CreatePipe() problem
    ... of those pipe handles? ... When CreatePipe call fails, what does ... GetLastError() returns 6 which means ERROR_INVALID_HANDLE. ...
    (microsoft.public.vc.language)