Back to the WFC main page


$Revision: 3 $


This class allows you to create shared memory objects easily. A shared memory segment is a chunk of memory that is shared between multiple processes in a system. Shared memory is great for things like holding status information. For example, you could have a process that reads position information from a GPS unit and puts it into shared memory. You could have many other applications connect to that shared memory and read the position data.

Data Members



void Close( void )
Closes the object. You can no longer use the pointer.
BOOL Create( const CString& object_name, DWORD size_in_bytes )
Creates a shared memory object. If the object specified by object_name already exists, you will attach to it. In other words, when Create() returns TRUE, you will have a shared memory object whether it was newly created or attached to an existing one.
void GetName( CString& object_name ) const
Returns the name of the shared memory object.
void * GetPointer( void ) const
Returns the pointer to the shared memory segment. It will return NULL if Create() has not yet been called.
DWORD GetSize( void ) const
Returns the size in bytes fo the shared memory object. It will return zero if Create() has not yet been called.


#include <wfc.h>
#pragma hdrstop

void update_time( constCString& queue_name )
   WFCTRACEINIT( TEXT( "update_time()" ) );

   CSharedMemoryObject queue;

   if ( queue.Create( queue_name, sizeof( APPLICATION_QUEUE ) != FALSE )
      APPLICATION_QUEUE * queue_p = NULL;

      queue_p = (APPLICATION_QUEUE *) queue.GetPointer();

      if ( queue_p != NULL )
         CSystemTime system_time;


         queue_p->last_updated = system_time;

API's Used

Copyright, 2000, Samuel R. Blackburn
$Workfile: CSharedMemoryObject.cpp $
$Modtime: 1/17/00 9:21a $