This example shows how to get access to a shared memory object.
#define INCL_DOSMEMMGR /* DOS Memory Management */ #define INCL_DOSERRORS /* DOS error values */ #include <os2.h> #include <stdio.h> int main (USHORT argc, PCHAR argv[]) { PVOID pvShrObject = NULL; /* Pointer to shared memory object */ APIRET rc = NO_ERROR; /* Return code */ /************************************************************************/ /* This example assumes that pvShrObject can be initialized here with */ /* a pointer to a shared memory object with the OBJ_GETTABLE attribute */ /* Normally this would be passed to this program via inter-process */ /* communication (IPC) - a pipe, a queue, a semaphore, the file system. */ /************************************************************************/ rc = DosGetSharedMem(pvShrObject, PAG_WRITE | PAG_READ); if (rc != NO_ERROR) { printf("DosGetSharedMem error: return code = %u\n", rc); return 1; } return NO_ERROR; }