[ Home |
Alpha index |
Topic index |
Tutorials |
Download |
Feedback ]
The OS/2 API Project
DosGetNamedSharedMem
[ Syntax |
Params |
Returns |
Include |
Usage |
Structs |
Gotchas |
Code |
Also ]
Syntax
rc = DosGetNamedSharedMem( pBaseAddress,
pszSharedMemName,
ulAttributeFlags );
Parameters
- PPVOID pBaseAddress (output)
- This is a pointer to the variable that should recieve the base address of the allocated
memory space.
- PSZ pszSharedMemName (input)
- This an optional address of a name string that is to be associated with the shared
memory block which we are about to allocate. The name should be in the format of an OS/2
filename, and is an ordinary ASCIIZ string. Will be stored in the \SHAREMEM\ subdirectory.
- ULONG ulAttributeFlags (input)
- Flags that describe the desired access protection and allocation attributes.
Access protection
- Setting PAG_READ (0x00000001) tells the system that read access is desired.
- Setting PAG_WRITE (0x00000002) tells the system that write access is desired.
- Setting PAG_EXECUTE (0x00000004) tells the system that execute access is
desired.
- Setting PAG_GUARD (0x00000008) tells the system that access to the memory object
should cause a guard page exception to be raised, in the subject process.
- At least one of PAG_READ,PAG_WRITE or PAG_EXECUTE must be set.
Returns
- APIRET rc
- The following values can be returned
-
0 | NO_ERROR |
2 | ERROR_FILE_NOT_FOUND |
8 | ERROR_NOT_ENOUGH_MEMORY |
87 | ERROR_INVALID_PARAMETER |
95 | ERROR_INTERRUPT |
123 | ERROR_INVALID_NAME |
212 | ERROR_LOCKED |
Include Info
#define INCL_DOSMEMMGR
#include <bsememf.h>
#include <os2.h>
Usage Explanation
DosGetNamedSharedMem is used to get access to a named shared memory block. This will
allocate the virtual address of the memory object into the process's virtual-address space.
If you specify the name of the block, the name string must include the prefix "\SHAREMEM\".
The returned address will be the same as the one returned to the process that created the
memory block.
Relevant Structures
Gotchas
Sample Code
#define INCL_DOSMEMMGR
#include
#include
PVOID BaseAddress;
/* Pointer to the base address of the allocated memory. */
UCHAR Name[40];
/* Pointer to the requested name of the memory block */
/* which we are about to allocate. */
ULONG AttributeFlags;
/* Flags describing the memory block's characteristics. */
APIRET rc;
/* Receiving the return code */
strcpy(Name,"\\SHAREMEM\\BLOCK.DAT");
/* Name of the shared memory block. */
/* Note the \\SHAREMEM\\ prefix. */
AttributeFlags = PAG_WRITE | PAG_READ | PAG_COMMIT;
/* We request read and write access to the shared memory */
/* block, and also have the pages of the memory block */
/* committed at once within the virtual memory. */
rc = DosGetNamedSharedMem( &BaseAddress, Name, AttributeFlags);
if (rc != 0)
{
/* We have an error we must take care of. */
}
See Also
DosAllocSharedMem, DosGetSharedMem, DosGiveSharedMem
Author
Stefan Mars -
mars@lysator.liu.se
Additions
Last modified March 16/1996
Please send all errors, comments, and suggestions to:
timur@vnet.ibm.com
The OS/2 API Project |
DosGetNamedSharedMem |