折腾2个小时,内存映射两个文件,一个成功了,另一个失败了,追踪原因是:DWORD dwNumberoftoMap1;
DWORD dwNumberoftoMap2;
映射成功时,dwNumberoftoMap1自动为0
失败时局部变量dwNumberoftoMap2自动为1241512,导致未映射整个文件。
有点奇怪,每次执行时dwNumberoftoMap2自动为1241512。删掉第一个映射dwNumberoftoMap2还是自动为1241512MapHeadAddress = MapViewOfFile(
hMapFile,
FILE_MAP_WRITE,
0,
0
dwNumberoftoMap2); Copymemory(Marklist,MapHeadAddress,17651844); 系统是window sever 2003 64bit, vs2005.哪位朋友解释下。
The number of bytes of a file mapping to map to the view. All bytes must be within the maximum size specified by CreateFileMapping. If this parameter is 0 (zero), the mapping extends from the specified offset to the end of the file mapping.MapViewOfFile()失败,你GetLastError()看下返回值。局部变量使用之前最好初始化,这是个好的编程习惯。