请问进程间的通信是如何做到的?
请各位提供一下思路

解决方案 »

  1.   


    方法很多:共享内存、WM_COPYDATA、socket、管道等等一般的进程间通信都是以共享内存为基础实现的。
      

  2.   

    我一般用发送消息
    前提是二者都有窗口
    FindWindow
    SendMessage
      

  3.   

    内存映射文件CreateFileMapping(),MapViewOfFile() ,
    用CreateFileMapping函数创建一个共享的内存块,在另一个程序中用MapViewOfFile函数可以得到这个内存块的地址,这样就可以访问这块内存了,达到进程之间通信的目的下面是个试例HANDLE hMapFile;hMapFile = CreateFileMapping(hFile,    // Current file handle. 
        NULL,                              // Default security. 
        PAGE_READWRITE,                    // Read/write permission. 
        0,                                 // Max. object size. 
        0,                                 // Size of hFile. 
        "MyFileMappingObject");            // Name of mapping object. 
     
    if (hMapFile == NULL) 

        ErrorHandler("Could not create file-mapping object."); 

    LPVOID lpMapAddress;
    lpMapAddress = MapViewOfFile(hMapFile, // Handle to mapping object. 
        FILE_MAP_ALL_ACCESS,               // Read/write permission 
        0,                                 // Max. object size. 
        0,                                 // Size of hFile. 
        0);                                // Map entire file. 
     
    if (lpMapAddress == NULL) 

        ErrorHandler("Could not map view of file."); 

    The second process calls the OpenFileMapping function with the name MyFileMappingObject to use the same file-mapping object as the first process. Like the first process, the second process uses the MapViewOfFile function to obtain a pointer to the file view. HANDLE hMapFile;
    LPVOID lpMapAddress;hMapFile = OpenFileMapping(FILE_MAP_ALL_ACCESS, // Read/write permission. 
        FALSE,                             // Do not inherit the name
        "MyFileMappingObject");            // of the mapping object. 
     
    if (hMapFile == NULL) 

        ErrorHandler("Could not open file-mapping object."); 

     
    lpMapAddress = MapViewOfFile(hMapFile, // Handle to mapping object. 
        FILE_MAP_ALL_ACCESS,               // Read/write permission. 
        0,                                 // Max. object size. 
        0,                                 // Size of hFile. 
        0);                                // Map entire file. 
     
    if (lpMapAddress == NULL) 

        ErrorHandler("Could not map view of file.");