memory mapped file with Dll

 

hi guys  i try to read a memory mapped file  with Dll   https://www.mql5.com/en/code/download/816/memmap32.zip

but i  have some problem  i try to load  with this  scriptin mql4

//+------------------------------------------------------------------+
//|                                           Standard Deviation.mq4 |
//|                      Copyright © 2005, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net/"

#property indicator_separate_window
#property indicator_minimum 0
#property indicator_buffers 1
#property indicator_color1 Blue
#define modeOpen                                                0 // open mode
#define HEAD            8             // header size

#import "MemMap32.dll"
int MemOpen(string path,int size,int mode,int &err);                // open/create memory-mapped file and returns handle
void MemClose(int hmem);                                            // close memory mapped file
int MemGrows(int hmem, string path,int newsize,int &err);      // increase size of memory-mapped file
int MemWrite(int hmem,int &v[], int pos, int sz, int &err);         // write v vector (sz bytes) to memory-mapped file starting from position pos
int MemRead(int hmem, int &v[], int pos, int sz, int &err);         // read v vector (sz bytes) from memory-mapped file starting from position pos
int MemWriteStr(int hmem, uchar &str[], int pos, int sz, int &err); // write string
int MemReadStr(int hmem, uchar &str[], int pos, int &sz, int &err); // read string 
#import

string NameFile="dllmemfilemap";
int err;
int head[2];
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
 int hmem=MemOpen(NameFile,-1,modeOpen,err); // open file
    if(hmem>0) // if opened successfully
     {
       string r=MemRead(hmem, head,0,HEAD,err);
        Print("read head uses="+head[0]+"  adr="+head[1]+"  | r="+r+"  err="+err);
     }

   return (0);
  }




//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   return(0);
  }
//+------------------------------------------------------------------+
//| Standard Deviation                                               |
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+

i want load a string dllmemfilemap

i write them in memap  with  this code C++

#include <windows.h>
#include <stdio.h>
#include <conio.h>
#include <tchar.h>

#define BUF_SIZE 4096
TCHAR szName[] = TEXT("dllmemfilemap");
TCHAR szMsg[] = TEXT("Message from first process.");

int _tmain()
{
    HANDLE hMapFile;
    LPCTSTR pBuf;

    hMapFile = CreateFileMapping(
        INVALID_HANDLE_VALUE,    // use paging file
        NULL,                    // default security
        PAGE_READWRITE,          // read/write access
        0,                       // maximum object size (high-order DWORD)
        BUF_SIZE,                // maximum object size (low-order DWORD)
        szName);                 // name of mapping object

    if (hMapFile == NULL)
    {
        _tprintf(TEXT("Could not create file mapping object (%d).\n"),
            GetLastError());
        return 1;
    }
    pBuf = (LPTSTR)MapViewOfFile(hMapFile,   // handle to map object
        FILE_MAP_ALL_ACCESS, // read/write permission
        0,
        0,
        BUF_SIZE);

    if (pBuf == NULL)
    {
        _tprintf(TEXT("Could not map view of file (%d).\n"),
            GetLastError());

        CloseHandle(hMapFile);

        return 1;
    }


    CopyMemory((PVOID)pBuf, szMsg, (_tcslen(szMsg) * sizeof(TCHAR)));
    _getch();

    UnmapViewOfFile(pBuf);

    CloseHandle(hMapFile);

    return 0;
}


but  return me  2020.10.05 14:22:30.692    IndtestMemMap EURUSD,H4: read head uses=7536755  adr=6750305  | r=8  err=0

anyone  have  some idea why not return a string _ thankz  at all

Reason: