这个例子http://msdn.microsoft.com/en-us/library/windows/desktop/aa366551(v=vs.85).aspx传递了一个 TCHAR,但我怎样才能让它传递一个 DWORD?我在下面尝试过,但无法将参数 1 从“DWORD *”转换为“const wchar_t *”。
DWORD* pid=new DWORD[20];
HANDLE hMapFile;
DWORD pBuf;
TCHAR szName[]=TEXT("Global\\mapFile");
//il creez
hMapFile = CreateFileMapping(
INVALID_HANDLE_VALUE, // use paging file
NULL, // default security
PAGE_READWRITE, // read/write access
0, // maximum object size (high-order DWORD)
256, // 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 = (DWORD) MapViewOfFile(hMapFile, // handle to map object
FILE_MAP_ALL_ACCESS, // read/write permission
0,
0,
256);
if (pBuf == NULL)
{
_tprintf(TEXT("Could not map view of file (%d).\n"),
GetLastError());
CloseHandle(hMapFile);
return 1;
}
CopyMemory((LPVOID)pBuf, pid, (_tcslen(pid) * sizeof(TCHAR)));