折腾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.哪位朋友解释下。

解决方案 »

  1.   

    初始化一下呗,至于为什么是那个值,64bit的就不知道了.
      

  2.   

    dwNumberOfBytesToMap 
    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()看下返回值。局部变量使用之前最好初始化,这是个好的编程习惯。
      

  3.   

    release程序版本局部变量不初始化时,值无法确定,取决于运行时刻分配给它的堆栈内存的值
      

  4.   

    debug下普通变量初始化成0xcc, 0xcccc,或0xccccccccrelease是随机数。static变量是0