如何向以创建好的共享内存中写入数据

怎么向以创建好的共享内存中写入数据
buffer=(char*)MapViewOfFile(hfilemap,FILE_MAP_ALL_ACCESS,0,0,100*sizeof(double));(我已经create过)
比如我想往共享内存中写入一个按钮信息,应该怎么写呢,*(buffer+1)之类的总是提示有错,应该是指针问题吧
我是在一个回调函数中进行操作的

------解决方案--------------------
MSDN上的例子代码,一个写,一个读
C/C++ code

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

#define BUF_SIZE 256
TCHAR szName[]=TEXT("Global\\MyFileMappingObject");
TCHAR szMsg[]=TEXT("Message from first process");

int main()
{
   HANDLE hMapFile;
   LPCTSTR pBuf;

   hMapFile = CreateFileMapping(
                 INVALID_HANDLE_VALUE,    // use paging file
                 NULL,                    // default security 
                 PAGE_READWRITE,          // read/write access
                 0,                       // max. object size 
                 BUF_SIZE,                // buffer size  
                 szName);                 // name of mapping object
 
   if (hMapFile == NULL) 
   { 
      printf("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) 
   { 
      printf("Could not map view of file (%d).\n", 
             GetLastError()); 
      return 2;
   }

   
   CopyMemory((PVOID)pBuf, szMsg, strlen(szMsg));
   _getch();

   UnmapViewOfFile(pBuf);

   CloseHandle(hMapFile);

   return 0;
}

------解决方案--------------------
MapViewOfFile后要UnmapViewOfFile