memory mapped file

 

Hi guys  i try to read  a memory mapped file , the   first script is simply c++

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

#define BUF_SIZE 256
TCHAR szName[] = TEXT("MyFileMappingObject");
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;
}

by microsoft msdn

and second i mod   some example in forum  but return me could not open file mapping 0

//+------------------------------------------------------------------+
//|                                           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 BUF_SIZE 256
extern string szName = "MyFileMappingObject";
#import "kernel32.dll"
int OpenFileMappingA(string dwDesiredAccess, bool bInheritHandle, string lpName);
int MapViewOfFile(int hFileMappingObject, string dwDesiredAccess, int dwFileOffsetHigh, int dwFileOffsetLow, int dwNumberOfBytestoMap);
bool CloseHandle(long handle);
bool UnmapViewOfFile(string lpBaseAddress);
#import

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   int handle = 0;
   string pBuf;

   handle = OpenFileMappingA("FILE_MAP_ALL_ACCESS", FALSE, 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);
  }

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {


   return(0);
  }
//+------------------------------------------------------------------+
//| Standard Deviation                                               |
//+------------------------------------------------------------------+

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

any one can help me ???

thankz

Reason: