windows下程序通訊有很多方式,跨裝置通訊一般使用 tcp udp,如果在同一臺電腦上 使用 管道 和 共享記憶體還是比較方便的。
下面說下windows下共享記憶體的使用。
程序一:(1)建立共享記憶體區域
注意:共享記憶體裡的資料不會自動清空#include #include using namespace std;
#define buf_size 4096
int main()
程序二:(1)開啟共享記憶體區域
#include #include using namespace std;
#define buf_size 4096
int main()
; strcpy_s(szbuffer, (char*)lpmap );
// 解除檔案對映
unmapviewoffile(lpmap );
// 關閉記憶體對映檔案物件控制代碼
closehandle(hmapfile);
}else
return 0;
}
windows下共享記憶體
建立共享記憶體 define buf size res 1025 invalid handle value,物理檔案控制代碼 null,預設安全級別 page readwrite,可讀可寫 0,高位檔案大小 buf size res,地位檔案大小 sznameresult 共享記憶體名稱 char ...
Windows共享記憶體
windows共享記憶體可以讓兩個程序對同一塊記憶體進行讀寫。a.cpp include include include include include using namespace std define buf size 256tchar szname text 指向同一塊共享記憶體的名字 in...
Windows共享記憶體示例
windows共享記憶體可以讓兩個程序對同一塊記憶體進行讀寫。a.cpp include include include include include using namespace std define buf size 256tchar szname text 指向同一塊共享記憶體的名字 in...