如何用CreateFileMapping实现进程之间共享数据
HANDLE hMapFile = CreateFileMapping(INVALID_HANDLE_VALUE,NULL,PAGE_READWRITE,0,4*1024,"XQ");
if (hMapFile == NULL)
{
MessageBox(NULL,"程序异常!","信息",MB_OK);
}
LPVOID lpMapAddress = MapViewOfFile(hMapFile,FILE_MAP_ALL_ACCESS,0,0,0);
if (lpMapAddress == NULL)
{
MessageBox(NULL,"程序异常!","信息",MB_OK);
}
else
{
char szPath[MAX_PATH];
GetCurrentDirectory(MAX_PATH,szPath);
(char *)lpMapAddress = szPath;
UnmapViewOfFile(lpMapAddress);
}
HANDLE hMapFile = OpenFileMapping(FILE_MAP_ALL_ACCESS,false,"XQ");
if (hMapFile == NULL)
{
MessageBox(NULL,"程序异常","信息",MB_OK);
}
LPVOID lpMapAddress = MapViewOfFile(hMapFile,FILE_MAP_ALL_ACCESS,0,0,0);
if (lpMapAddress == NULL)
{
MessageBox(NULL,"程序异常","信息",MB_OK);
}
else
{
Form2->Caption = AnsiString((char *)lpMapAddress); //这边得到的不是上面的值
UnmapViewOfFile(lpMapAddress);
}
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课