Re: SetNamedPipeHandleState problems??
- From: "Tom Stewart" <tastewar@xxxxxxxxxxxxxxxx>
- Date: Tue, 15 Nov 2005 20:09:46 -0500
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
.
- Follow-Ups:
- Re: SetNamedPipeHandleState problems??
- From: FredsFriend
- Re: SetNamedPipeHandleState problems??
- Prev by Date: Re: Callback function for failed disk write?
- Next by Date: Re: Callback function for failed disk write?
- Previous by thread: Re: Understandng Spy++ Technique
- Next by thread: Re: SetNamedPipeHandleState problems??
- Index(es):
Relevant Pages
|