麻烦一点的方法是用socket,或者WM_COPYDATA

解决方案 »

  1.   

    麻烦一点的方法是用socket,或者WM_COPYDATA
      

  2.   

    加入以下代碼入你的DLL
    #pragma data_seg("MySharedData")
    // 你的變量定量, 如
    int a;
    #pragma data_seg()
    // Instruct the linker to make the Shared section
    // readable, writtable and shared
    #pragma comment(linker, "/section:MySharedData,rws")
      

  3.   

    我用了内存映射文件,三个步骤:CreateFile,CreateFileMapping,MapViewOfFile都正确,
    在进程中用地址空间的句柄读取数据也正确,但是DLL中得不到数据。
    请教:
     (1) pBuf = MapViewOfFile(.....);
       ((char *)pBuf)[0] = 1;
     是不是可以直接给地址空间赋值,
     (2)需要什么处理能保证物理空间与地址空间内容的一致性?
     (3)三个步骤中与此相关的参数如何设置保证成功?