64,650
社区成员
发帖
与我相关
我的任务
分享
HANDLE hMapFile = NULL;
char *szData = NULL;
hMapFile = OpenFileMapping(PAGE_READWRITE, NULL, "TEST");
if (hMapFile == NULL)
{
printf("The First Program, It Will Create Mapping File\n");
hMapFile = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 4*1024, "TEST");
if (hMapFile == NULL)
{
printf("Create Mapping File Failed\n");
system("PAUSE");
return 0;
}
}
else
{
printf("Program Has been open more than once\n");
}
szData = (char*)MapViewOfFile(hMapFile, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0);
if (szData == NULL)
{
// ERROR_ACCESS_DENIED 5 (0x5) Access is denied.
printf("Map View Of FIle Failed, %d\n", GetLastError());
CloseHandle(hMapFile);
system("PAUSE");
return 0;
}
lpAttributes
[in] Pointer to a SECURITY_ATTRIBUTES structure that determines whether the returned handle can be inherited by child processes. If lpAttributes is NULL, the handle cannot be inherited.
Windows NT/2000/XP: The lpSecurityDescriptor member of the structure specifies a security descriptor for the new file-mapping object. If lpAttributes is NULL, the file-mapping object gets a default security descriptor.