Memory Mapped file without dll and persistent file

 

hi guys  i try to  read in MT4 a  Memory mapped file , i look this  example

https://www.mql5.com/en/forum/142721

i have created  a C#  memory mapped file  this is a code

using System;
using System.IO;
using System.IO.MemoryMappedFiles;
using System.Threading;

class Program
{
    // Process B:
    static void Main(string[] args)
    {
        try
        {
            using (MemoryMappedFile mmf = MemoryMappedFile.OpenExisting("Test"))
            {

                Mutex mutex = Mutex.OpenExisting("testmapmutex");
                mutex.WaitOne();

                using (MemoryMappedViewStream stream = mmf.CreateViewStream(1, 0))
                {
                    BinaryWriter writer = new BinaryWriter(stream);
                    writer.Write("0");
                }
                mutex.ReleaseMutex();
            }
        }
        catch (FileNotFoundException)
        {
            Console.WriteLine("Memory-mapped file does not exist. Run Process A first.");
        }
    }
}

(in C#  work also a reading file )

at  this point  i would read a  memory mapped file  by  MT4 , i try  with this code 

#define BUF_SIZE 256
extern string szName = "Global\\Test";
#import "kernel32.dll"
#import
int OpenFileMappingA(string dwDesiredAccess, bool bInheritHandle, string lpName);

int MapViewOfFile(int hFileMappingObject, string dwDesiredAccess, int dwFileOffsetHigh, int dwFileOffsetLow, int dwNumberOfBytestoMap);
bool CloseHandle(int handle);
bool UnmapViewOfFile(string lpBaseAddress);

int start()
  {
   int handle = 0;
   string pBuf;
   
   handle = OpenFileMappingA(NULL, TRUE, szName);
   if(handle == 0) Alert("Could not open file mapping object", GetLastError());
   //Alert("next");
   pBuf = MapViewOfFile(handle, NULL, 0, 0, BUF_SIZE);
   /*if(pBuf == 0)
   {
      Alert("Could not map view of file");
      CloseHandle(handle);      
   }*/
   Alert(pBuf);
   UnmapViewOfFile(pBuf);
   CloseHandle(handle);
   return (0);
  }

but return me  error  'OpenFileMappingA' - function must have a body    TestMMP.mq4    18    5

why ? should be import by kernel32 ? , (i work with win 10 64 bit )

thnakz


shouldn't it import it from kernel32? shouldn't it import it from kernel32? shouldn't it import it from kernel32? shouldn't it import it from kernel32? shouldn't it import it from kernel32?
OpenFileMappingA, sharing data between MQL4 and C++ program
OpenFileMappingA, sharing data between MQL4 and C++ program
  • 2012.12.23
  • www.mql5.com
Hi, I'm trying to get an MQL4 program to talk to a C++ program via memory space instead of file handling...
Reason: