|
- Managing the share mode
- Correspondence between the name provided to fMemOpen and the opening in C
- Managing the memory zones in UNICODE format
- Positioning in the shared memory zone
- Closing the shared memory zone
fMemOpen (Function) In french: fMemOuvre Opens a memory zone shared between several applications.
// Create/Open a memory zone 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 zone shared // between applications (2nd application) - // no callback Zone2ID is int Zone2ID = fMemOpen("MySharedZone", 1024, shareGlobal) // Write into the shared memory zone 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 by WINDEV whenever the shared memory zone 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(<Name of memory zone> , <Size> [, <Share> [, <Opening mode> [, <Procedure name>]]])
<Result>: Integer - Identifier of the memory zone.
This identifier can be handled by the fxxx functions like an identifier of external file returned by fOpen. - -1 if an error occurred.
<Name of memory zone>: Character string (with quotes) Name of the shared memory zone 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 zone 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 zone 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. | | foWrite | The zone is opened in "write only". You will only have the ability to write into this 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 zone, you must close the memory zone ( 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. (See the Notes for more details) |
<Procedure name>: Optional character string (with or without quotes) 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 zones. 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: - Linux, Windows 2000 and earlier: if there is a single space for creating the memory zone, the <Share> parameter of fMemOpen is ignored.
- Windows XP: the <Share> parameter of fMemOpen is effective if the service for quick change of user is enabled, otherwise it is ignored.
- Windows Vista and later: the <Share> parameter of fMemOpen is managed. The services and the users are located in a different space. To share a memory zone 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 managed. Each session opened on the Terminal Server has a different memory space. The applications started in the same TSE session can share a memory zone 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 zones in UNICODE format fMemOpen is used to read and write memory zones in UNICODE "UTF-16" or in "little endian" format. At opening, the "current Unicode" mark (FFFE) is automatically read. At creation, it is automatically added. Note: 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 zone When opening a shared memory zone, the current position corresponds to the first byte of the zone. This position can be modified by fSeek. Closing the shared memory zone When the application does no longer need to access the shared memory zone, 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…
|
|
|
| |
| Click [Add] to post a comment |
|
| |
|
| |
| |
| |
| |
| |
| |
| | |
| |