
CNamedPipe v1.10 An MFC class
to encapsulate Named Pipes
The class encapsulates the Named Pipe Inter Process Communication
mechanism as provided in Win32.
The class provides a thin veneer of the SDK API meaning
that all the richness the SDK provides is available through the class. The class also
provides auto cleanup and is UNICODE enabled with build configurations provided.
The enclosed zip file contains the
CNamedPipe source code and also includes a VC 2005 solution to build a small demonstration
app.
Copyright
- You are allowed to include the source code in
any product (commercial, shareware, freeware or otherwise) when your product
is released in binary form.
- You are allowed to modify the source code in
any way you want except you cannot modify the copyright details at the top
of each module.
- If you want to distribute source code with
your application, then you are only allowed to distribute versions released
by the author. This is to maintain a single distribution point for the
source code.
Updates
v1.0 (3 August 1998)
V1.01 (21 February 2002)
- Updated copyright message in source code and
documentation
- Fixed a bug in Close method where the handle value was
not being reset to INVALID_HANDLE_VALUE.
- Tidied up the TRACE code
- Tidied up build configurations for sample apps
V1.02 (28 July 2002)
- Updated sample server app to do Flush of the pipe before we disconnect the client. Thanks to "Martin" for spotting this problem.
V1.03 (9 November 2002)
- ConnectClient now returns TRUE if the last error returns ERROR_PIPE_CONNECTED which indicates that a client is already connected before we make the call. Thanks to Metrich Frederic
for reporting this.
V1.04 (5 March 2003)
- Changed the class to use exceptions rather than SDK
style return values.
V1.05 (12 November 2003)
- Attach now includes an AutoClose parameter. This allows
control over whether the pipe handle should be closed when the pipe object
goes out of scope or CNamedPipe::Close is called. Thanks to Metrich Frederic
for reporting this issue.
V1.06 (19 November 2003)
- Fixed ASSERT's at the start of most CNamedPipe
functions which verify that the pipe handle is valid. Thanks to Metrich
Frederic for reporting this issue.
V1.07 (15 July 2006)
- Updated copyright details.
- Renamed AfxThrowNamedPipeException to ThrowNamedPipeException and made
it part of the CNamedPipe class.
- CNamedPipe is no longer derived from CObject as it was not really
required.
- Optimized CNamedPipe constructor code.
- Code now uses new C++ style casts rather than old style C casts where
necessary.
- Optimized CNamedPipeException constructor code
- Removed the unnecessary CNamedPipeException destructor
- Removed some unreferenced variables in the sample app.
- Updated the code to clean compile on VC 2005
- Updated documentation to use the same style as the web site.
- Addition of a CNAMEDPIPE_EXT_CLASS macro to allow the classes to be
easily added to an extension dll.
V1.08 (29 November 2007)
- Updated copyright details.
- Updated the sample apps to clean compile on VC 2005
- Sample client app now defaults to "." (meaning the current machine) as
the server to connect to.
- CNamedPipeException::GetErrorMessage now uses the
FORMAT_MESSAGE_IGNORE_INSERTS flag. For more information please see Raymond
Chen's blog at
http://blogs.msdn.com/oldnewthing/archive/2007/11/28/6564257.aspx.
Thanks to Alexey Kuznetsov for reporting this issue.
- CAppSettingsException::GetErrorMessage now uses Checked::tcsncpy_s if
compiled using VC 2005 or later.
- Provision of new overloaded versions of the Peek, Write and Read
methods which allows the dwBytesRead/dwBytesWritten parameters to be
returned as an output parameter as opposed to the return value of the
method. This helps resolve a situation where the underlying WriteFile /
ReadFile call fails but some data has actually been written / read from the
pipe. Thanks to Gintautas Kisonas for reporting this issue.
- dwBytesRead, dwTotalBytesAvail and dwBytesLeftThisMessage parameters to
Peek are now pointers rather than references. Thanks to Gintautas Kisonas
for reporting this issue.
V1.09 (30 November 2007)
- Updated the sample apps to clean compile on VC 2008
V1.10 (12 July 2008)
- Updated copyright details.
- Updated sample app to clean compile on VC 2008
- The code has now been updated to support VC 2005 or later only.
- Code now compiles cleanly using Code Analysis (/analyze)
- Removed the m_bAutoClose member variable and concept from class