传递DWORD*到映射文件
Passing DWORD* to mapped file
这个例子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)));
Mapviewoffile返回LPVOID。下一种工作方式:
DWORD* 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, (20* sizeof(DWORD)));
相关文章:
- C/C++ - 查询平台相关的换行符(用于内存映射文件)
- 写入映射文件
- 内存映射文件访问非常慢
- 我正在尝试创建一个C++映射,该映射在boost内存映射文件中具有向量值
- 无法从地址打开映射文件
- 为什么 du -sh 输出错误大小的内存映射文件
- 使用 mmap 映射文件中的不同段
- Growing Boost.使用单个写入器的进程间内存映射文件
- 调整窗口内存映射文件的大小,而不会使指针失效
- 映射文件中成员结构的地址
- 与从C++到C#的内存映射文件共享链式结构
- 在 C++ 和 C# 之间共享内存映射文件结构
- 如何使用 Boost 的"mapped_file_sink"类刷新内存映射文件?
- 使用Solaris 64位或Linux 32位到Linux 64位的内存映射文件
- 循环访问提升mapped_region/内存映射文件
- 使用 Win32/WINAPI 通过内存映射文件传输数据
- qtCreator 错误:无法映射文件,errno=22 文件用于架构x86_64?
- 复制存储在内存映射文件中的数组的一部分
- 用于读取输入文件的内存映射文件的安全
- 写入和读取映射文件C++