This is part of Family API which allow to create dual-os version of program runs under OS/2 and DOS

Note: This is legacy API call. It is recommended to use 32-bit equivalent

DosAllocShrSeg

This call allocates a named shared memory segment to a process.

Syntax

DosAllocShrSeg (Size, Name, Selector)

Parameters

Size (USHORT) - input : Number of bytes requested. The value specified must be less than or equal to 65535. A value of 0 indicates 65536 bytes.

Name (PSZ) - input : Address of the name string associated with the shared memory segment to be allocated. Name specifies the symbolic name for the shared memory segment. The name string is an ASCIIZ string in the format of an OS/2 file name in a subdirectory called \SHAREMEM\. The name string must include the prefix \SHAREMEM\. For example \SHAREMEM\name.

Selector (PSEL) - output : Address where the selector of the allocated segment is returned.

Return Code

rc (USHORT) - return:Return code descriptions are:

0 NO_ERROR

8 ERROR_NOT_ENOUGH_MEMORY

123 ERROR_INVALID_NAME

183 ERROR_ALREADY_EXISTS

Remarks

DosAllocShrSeg allocates a named segment of up to 64KB in size, which is movable and swappable. The segment can be shared by any process that knows the name of the segment.

To access the shared segment, another process issues DosGetShrSeg, specifying the segment name. The selector returned by DosGetShrSeg is the same as the one returned by DosAllocShrSeg.

The maximum number of segments a process can define with DosAllocShrSeg or access with DosGetShrSeg is 256.

;Note: This request may be issued from privilege level 2. However, the segment is allocated as a privilege level 3 segment.

Bindings

C

#define INCL_DOSMEMMGR USHORT rc = DosAllocShrSeg(Size, Name, Selector); USHORT Size; /* Number of bytes requested */ PSZ Name; /* Name string */ PSEL Selector; /* Selector allocated (returned) */ USHORT rc; /* return code */

MASM

EXTRN DosAllocShrSeg:FAR INCL_DOSMEMMGR EQU 1 PUSH WORD Size ;Number of bytes requested PUSH@ ASCIIZ Name ;Name string PUSH@ WORD Selector ;Selector allocated (returned) CALL DosAllocShrSeg Returns WORD

Example Code

This example requests a segment of memory with 27 bytes named “stock.dat”.

#define INCL_DOSMEMMGR #define NUMBER_OF_BYTES 27 #define NAME_SEG "\\SHAREMEM\\stock.dat" SEL Selector; USHORT rc; rc = DosAllocShrSeg(NUMBER_OF_BYTES, /* # of bytes requested */ NAME_SEG, /* Name string */ &Selector); /* Selector allocated */
Family API
DOS	Process Manager	DosBeep DosExit DosSleep DosExecPgm
File Manager	DosChDir DosChgFilePtr DosClose DosDelete DosDupHandle DosMkDir DosMove DosQCurDir DosQCurDisk DosSetFileMode DosOpen DosQFileInfo DosRead DosQFileMode DosQFSInfo DosQVerify DosRmDir DosSelectDisk DosFindClose DosFindFirst DosFindNext DosSetFileInfo DosSetVerify DosWrite DosFileLocks DosSetFHandState DosNewSize DosBufReset DosQFHandState DosSetFSinfo DosShutdown
Memory Manager	DosFreeSeg DosSubAlloc DosSubFree DosSubSet DosAllocHuge DosAllocSeg DosReallocHuge DosReallocSeg DosGetHugeShift DosCreateCSAlias
NLS	DosCaseMap DosGetCtryInfo DosGetDBCSEv DosSetCtryCode DosGetCollate DosGetMessage DosInsMessage DosPutMessage
Date and Time	DosSetDateTime DosGetDateTime
Devices	DosDevConfig DosDevIOCtl DosDevIOCtl2
Signals	DosHoldSignal DosSetSigHandler
Misc	BadDynLink DosGetEnv DosGetMachineMode DosGetVersion DosError DosErrClass DosSetVec
KBD	KbdCharIn KbdFlushBuffer KbdGetStatus KbdSetStatus KbdStringIn KbdPeek
VIO	VioGetBuf VioGetConfig VioGetCurPos VioGetCurType VioGetPhysBuf VioReadCellStr VioReadCharStr VioScrollUp VioScrollDn VioScrollLf VioScrollRt VioScrUnLock VioSetCurPos VioSetCurType VioSetMode VioGetMode VioShowBuf VioWrtCellStr VioWrtCharStr VioWrtCharStrAtt VioWrtNAttr VioWrtNCell VioWrtNChar VioWrtTTY VioScrLock VioPopUp
Tools	BIND
Modules	DOSCALLS.DLL VIOCALLS.DLL KBDCALLS.DLL MSG.DLL
Libraries	API.LIB OS2386.LIB FAPI.LIB DOSCALLS.LIB SUBCALLS.LIB