CAnonymousPipe v1.0
Welcome to CAnonymousPipe v1.0, A freeware MFC class to encapsulate the anonymous Pipe IPC method as provided in Win32.
Features |
Usage |
History |
API Reference |
Planned Enhancements |
Contacting the Author |
V1.0 (2 August 1998)
The API consists of the class CAnonymousPipe and its public member functions
CAnonymousPipe
~CAnonymousPipe
Create
Close
Write
Read
Peek
IsOpen
AssertValid
Dump
CAnonymousPipe::CAnonymousPipe
CAnonymousPipe();
Remarks
Standard default constructor. Initialises the pipe handles to a default value.
See Also
CAnonymousPipe::~CAnonymousPipe
~CAnonymousPipe();
Remarks
Standard default destructor. Will close any pipe handles which are still open
See Also
BOOL Create(LPSECURITY_ATTRIBUTES lpPipeAttributes = NULL, DWORD dwSize = 0);
Return Value
Non-Zero if the anonymous pipe was successfully created otherwise FALSE. Use GetLastError to get extended error information.
Parameters
lpSecurityAttributes Pointer to a SECURITY_ATTRIBUTES structure that specifies a security descriptor for the new anonymous pipe and determines whether child processes can inherit the returned handle. If lpSecurityAttributes is NULL, the named pipe gets a default security descriptor and the handle cannot be inherited.
nSize Specifies the buffer size for the pipe. The size is only a suggestion; the system uses the value to calculate an appropriate buffering mechanism. If this parameter is zero, the system uses the default buffer size.
Remarks
Creates an anonymous server side pipe. Unlike named pipes this function will work on non NT platforms including Windows 95 and Windows 98.
BOOL Close();
Return Value
Non zero if the anonymous pipe was closed otherwise FALSE. Use GetLastError to get extended error information.
Remarks
Closes the pipe
BOOL Write(LPCVOID lpBuffer, DWORD dwNumberOfBytesToWrite, DWORD& dwNumberOfBytesWritten);
Return Value
Non zero if the write succeeded otherwise FALSE. To get extended error information use GetLastError.
Parameters
lpBuffer Points to the buffer containing the data to be written to the pipe.
dwNumberOfBytesToWrite Specifies the number of bytes to write to the pipe.
dwNumberOfBytesWritten Points to the number of bytes written by this function call. Write sets this value to zero before doing any work or error checking.
Remarks
Performs a write to the anonymous pipe in a synchronous manner.
BOOL Read(LPVOID lpBuffer, DWORD dwNumberOfBytesToRead, DWORD& dwNumberOfBytesRead);
Return Value
Non zero if the Read succeeded otherwise FALSE. To get extended error information use GetLastError.
Parameters
lpBuffer Points to the buffer to receive the data to be read.
dwNumberOfBytesToWrite Specifies the number of bytes to read from the pipe.
dwNumberOfBytesWritten Points to the number of bytes read by this function call. Read sets this value to zero before doing any work or error checking.
Remarks
Performs a read from the anonymous pipe in a synchronous manner.
BOOL Peek(LPVOID lpBuffer, DWORD dwBufferSize, DWORD& dwBytesRead, DWORD& dwTotalBytesAvail, DWORD& dwBytesLeftThisMessage);
Return Value
Non zero if the function succeeds otherwise FALSE. To get extended error information use GetLastError.
Parameters
lpBuffer Points to a buffer that receives data read from the pipe. This parameter can be NULL if no data is to be read.
dwBufferSize Specifies the size, in bytes, of the buffer specified by the lpBuffer parameter. This parameter is ignored if lpBuffer is NULL.
dwBytesRead 32-bit variable that receives the number of bytes read from the pipe.
dwTotalBytesAvail 32-bit variable that receives the total number of bytes available to be read from the pipe.
dwBytesLeftThisMessage 32-bit variable that receives the number of bytes remaining in this message. This parameter will be zero for byte-type named pipes
Remarks
Copies data from the pipe into a buffer without removing it from the pipe. It also returns information about data in the pipe.
BOOL IsOpen() const;
Return Value
Non zero if the pipe is open otherwise FALSE.
virtual void AssertValid();
Remarks
Standard MFC override which performs a validity check on this instance.
virtual void Dump(CDumpContext& dc) const;
Parameters
dc
The diagnostic dump context for dumping, usually afxDump.Remarks
Standard MFC override which performs a dump to the dump context as provided by "dc".
PJ Naughter
Email: pjn@indigo.ie
Web: http://indigo.ie/~pjn
2 August 1998