我试图发送一个* var,实际上是一个4槽阵列,从一个应用程序发送到另一个管道在win32中。我怎样才能正确地做到这一点?通过管道发送结构数组:win32,C
据我所知,我在做正确:
//sending like this:
if (!WriteFile(hPipeWriteGhosts[i],Ghosts, (DWORD) sizeof(map)*4, &n, NULL))
{
printf("[ERROR] Writing in the pipe... (WriteFile)\n");
exit(1);
}
//receiving like this
ret = ReadFile(HReadSPipe, Ghosts, sizeof(map)*4, &n, NULL); // Lê até ao numero de bytes for zero (pipe fechado) pk o cliente escreveu fim e n escreveu mais nada
if (!ret || !n)
MessageBox(hDlgGlobal, str, "Error", MB_YESNO | MB_ICONINFORMATION); // But in fact it shows me this all the time.
我怎样才能正确地做到这一点?
在此先感谢。
那些'鬼'是什么? – zmbq
Oh sorry Ghosts is a * map struct map { \t int x,xb; \t int y,yb; \t HBITMAP bitm; \t int TypeOfMessage; \t char * BelongToUser; //标识对象所有者(如果该对象是GG) \t char type [1]; // 0无关,1位图更新,其他东西 }; 它将存储sizeof(地图)* 4 –
它只是一个指向结构图的指针..鬼是sizeof(map)* 4 –