|
|
|
|
- Managing the share mode
- Correspondence between the name provided to fMemOpen and the opening in C
- Managing the memory areas in UNICODE format
- Positioning in the shared memory area
- Closing the shared memory area
fMemOpen (Function) In french: fMemOuvre Opens a memory zone shared between several applications. // Create/Open a memory area shared between applications (1st application) arrZoneID is associative array of int Zone1ID is int Zone1ID = fMemOpen("MySharedZone", 1024, shareGlobal, ... foReadWrite, ModificationProcedure) arrZoneID["MySharedZone"] = Zone1ID ... // Create/Open a memory area shared // between applications (2nd application) - // no callback Zone2ID is int Zone2ID = fMemOpen("MySharedZone", 1024, shareGlobal) // Write into the shared memory area fWrite(Zone2ID, "Hello, I am a WINDEV application!") ... // The writing performed by the 2nd application triggers // the call to the procedure in the 1st application
// ------------------------- // Procedure called whenever the shared memory area is modified PROCÉDURE ModificationProcedure(NameNotifZone is string) ModifiedString is string ModifiedString = fRead(arrZoneID[NameNotifZone], 1024) Trace(StringBuild("The %1 string was written into the %2 zone", ModifiedString, NameNotifZone))
Syntax
<Result> = fMemOpen(<Memory area> , <Size> [, <Share> [, <Opening mode> [, <WLanguage procedure>]]])
<Result>: Integer - Identifier of the memory area.
This identifier can be handled by the fxxx functions like an identifier of external file returned by fOpen. - -1 if an error occurred.
<Memory area>: Character string Name of the shared memory area that must be created or opened. This name must be the same in the different applications that access the zone. The zone is automatically created if it does not exist.
<Size>: Integer Minimum size of the shared memory zone in bytes.- If the zone already exists:
- if <Size> is equal to 0: this parameter is ignored and the size of the zone is returned by fSize.
- if <Size> is different from 0:
- if <Size> is too big, fMemOpen returns -1.
- the existing memory area is opened with a size at least equal to the parameter (the actual size is defined by the operating system and it is returned by fSize).
- If the zone does not exist, it is created with a size at least equal to the parameter (the actual size is defined by the operating system and it is returned by fSize).
<Share>: Optional Integer constant Mode for sharing the memory area between the user sessions: | | shareGlobal | The zone is shared between all the applications of all the computer sessions. | shareUser (Default value) | The zone is shared between all the applications of the user session. |
<Opening mode>: Optional Integer constant Constants used to define the access mode to the shared memory zone. | | foRead | The zone is opened in "read only". You will only have the ability to read this zone.If this constant is used, to change the opening mode of the memory area, you must close the memory area ( fClose) and re-open it with a different opening mode. | foReadWrite (Default value) | The zone is opened in "read/write". You will be able to read and modify this zone. | foUnicode | Open a file in UNICODE format. (For more details, see the Notes) | foWrite | The zone is opened in "write only". You will only have the ability to write into this zone. |
<WLanguage procedure>: Procedure name Name of the WLanguage procedure ("callback" procedure) that will be automatically called if the memory zone is modified by another WLanguage application. This procedure has the following format:
PROCEDURE <Procedure name>(<Zone name>) The parameter of this procedure is optional. It must be used when a unique callback is used to receive the notifications of several shared memory areas. The <Zone name> parameter will be prefixed by the "Global\" string if the zone was created with the shareGlobal constant and by the "Local\" string if the zone was created with the shareUser constant. Remarks The share mode differs according to the versions of the operating systems: - Windows Vista and later: the <Share> parameter of fMemOpen is supported. The services and the users are located in a different space. To share a memory area between a service and an application in a user session, the shareGlobal constant must be used.
- In Terminal Server: the <Share> parameter of fMemOpen is supported. Each session opened on the Terminal Server has a different memory space. The applications started in the same TSE session can share a memory area created with the shareUser constant. Several applications located in different sessions can share a memory zone created by the shareGlobal constant.
- Windows: The administrator rights are required to access a Global memory zone in write mode or in read mode.
Managing the memory areas in UNICODE format fMemOpen is used to read and write memory areas using UTF-16 or Little Endian Unicode. At opening, the "current Unicode" mark (FFFE) is automatically read. At creation, it is automatically added. Remark: The mechanism for automatic callback of a WLanguage procedure whenever the memory zone is modified by another application operates between WLanguage applications only. Positioning in the shared memory area When opening a shared memory area, the current position corresponds to the first byte of the zone. This position can be modified by fSeek. Closing the shared memory area When the application does no longer need to access the shared memory area, the access can be closed by fClose. The zone is effectively destroyed once the last application accessing it has closed the zone. If no explicit call to fClose is found in the code of the application, the closing will be automatically performed when the application ends.
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|