Memory Mapping – library MetaTrader 5

This project (Visual C++ 2010) contains 2 classes – CMemMapApi ΠΈ CMemMapFile.

They designed for working with memory mapped files. You can:

  • Create file in memory;
  • Write and read data from memory mapped file;
  • It provides an opportunity to exchange data between applications, including MetaTrader 4 ΠΈ МetaΠ’rader 5.
Using memory mapped files you can achieve a great performance in data exchange.
The main application is the data exchange:
  • Copying of the trades for several terminals on one PC
  • Quotes data exchange for the arbitrage Expert Advisors etc.

The memory mapped files can be used for a serve of the temporary data of the Expert Advisors.
The CMemMapApi class is just a wrapper of WinApi functions, that’s the difference between CMemMapFile and CMemMapApi.

The CMemMapFile is useful, because it serves file name, file handle and controls the checkings of file size. In contrast, CMemMapApi class can work with several memory mapped files.

In current project the exported DLL functions are organized in CMemMapApi for working with several memory-mapped files.
The CMemMapFile class is designed for working with memory mapped files in other C++ projects.

Exported functions:
//--- open/create memory-mapped file and returns handle
int MemOpen(string path,int size,int mode,int &err[]);
//--- closes memory mapped file
void MemClose(int hmem);             
//--- increases the size of memory-mapped file
int MemGrows(int hmem,string path,int newsize,int &err[]);
//--- returns the size of memory mapped file
int MemGetSize(int hmem, int &err[]);
//--- sets the size of memory mapped file
int MemSetSize(int hmem, int size, int &err[]);
//--- writes v vector (size bytes) to memory-mapped file starting from position pos
int MemWrite(int hmem,int &v[], int pos, int size, int &err[]);       
//--- reads v vector (size bytes) to memory-mapped file starting from position pos
int MemRead(int hmem, int &v[], int pos, int size, int &err[]);
//--- writes a string (size bytes) to memory-mapped file starting from position pos
int MemWriteStr(int hmem, string buf, int pos, int size, int &err[]);
//--- reads a string (size bytes) from memory-mapped file starting from position pos
int MemReadStr(int hmem, string buf, int pos, int &size, int &err[]);

Example of the DLL use:Β  Quotes Monitoring (memory-mapped file)

Alternative:  Exp_BrakeParb - EA MetaTrader 5

12.03. 2012: Fixed an error in MemWriteStr



πŸ“ˆ ROBOTFX MetaTrader Expert Advisors and Indicators to maximize profits and minimize the risks