CAnonymousPipe v1.08

Welcome to CAnonymousPipe, A freeware C++ class to encapsulate the anonymous Pipe IPC method as provided in Win32.

 

Features
Copyright
Usage
History
API Reference
Contacting the Author

 

 

 

Features

 

 

 

Copyright

 

 

 

Usage

 

 

 

History

v1.08 (9 April 2022)

v1.07 (3 May 2020)

v1.06 (2 June 2019)

v1.05 (25 September 2018)

1 May 2017

v1.04 (16 January 2016)

v1.03 (9 April 2015)

v1.02 (2 September 2008)

V1.01 (29 December 2006)

V1.0 (2 August 1998)

 

 

 

API Reference

The API consists of the class CAnonymousPipe and its public member functions

CAnonymousPipe
~CAnonymousPipe
Create
Close
Write
Read
Peek
IsOpen

GetWriteHandle
GetReadHandle

 

 

CAnonymousPipe::CAnonymousPipe

CAnonymousPipe();

Remarks

Standard default constructor. Initialises the pipe handles to a default value.

See Also

~CAnonymousPipe

 

CAnonymousPipe::~CAnonymousPipe

~CAnonymousPipe();

Remarks

Standard default destructor. Will close any pipe handles which are still open

See Also

CAnonymousPipe

 

CAnonymousPipe::Create

BOOL Create(LPSECURITY_ATTRIBUTES lpPipeAttributes = NULL, DWORD nSize = 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.

 

CAnonymousPipe::Close

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

 

CAnonymousPipe::Write

BOOL Write(LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, DWORD* lpNumberOfBytesWritten = NULL, LPOVERLAPPED lpOverlapped = NULL);

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.

pNumberOfBytesWritten Points to the number of bytes written by this function call.

lpOverlapped Standard OVERLAPPED pointer. This is normally set to NULL for blocking IO calls.

Remarks

Performs a write to the anonymous pipe.

 

CAnonymousPipe::Read

BOOL Read(LPVOID lpBuffer, DWORD dwNumberOfBytesToRead, DWORD* lpNumberOfBytesRead = NULL, LPOVERLAPPED lpOverlapped = NULL);

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.

nNumberOfBytesToWrite Specifies the number of bytes to read from the pipe.

lpNumberOfBytesWritten Points to the number of bytes read by this function call.

lpOverlapped Standard OVERLAPPED pointer. This is normally set to NULL for blocking IO calls.

Remarks

Performs a read from the anonymous pipe.

 

CAnonymousPipe::Peek

BOOL Peek(LPVOID lpBuffer, DWORD nBufferSize, DWORD* lpBytesRead = NULL, DWORD* lpTotalBytesAvail = NULL, DWORD* lpBytesLeftThisMessage = NULL);

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.

nBufferSize Specifies the size, in bytes, of the buffer specified by the lpBuffer parameter. This parameter is ignored if lpBuffer is NULL.

lpBytesRead Pointer to a 32-bit variable that receives the number of bytes read from the pipe.

lpTotalBytesAvail Pointer to a 32-bit variable that receives the total number of bytes available to be read from the pipe.

lpBytesLeftThisMessage Pointer to a 32-bit variable that receives the number of bytes remaining in this message.

Remarks

Copies data from the pipe into a buffer without removing it from the pipe. It also returns information about data in the pipe.

 

CAnonymousPipe::IsOpen

BOOL IsOpen() const;

Return Value

Non zero if the pipe is open otherwise FALSE.

 

CAnonymousPipe::GetWriteHandle

HANDLE GetWriteHandle() const;

Return Value

The underlying write HANDLE which the class encapsulates.

 

CAnonymousPipe::GetReadHandle

HANDLE GetReadHandle() const;

Return Value

The underlying read HANDLE which the class encapsulates.

 

 

 

Contacting the Author

PJ Naughter
Email: pjna@naughter.com
Web: http://www.naughter.com
9 April 2022