我正在尝试使用 win32 中的管道从一个应用程序到另一个应用程序发送一个 *var,这实际上是一个 4 插槽数组。我怎样才能正确地做到这一点?
据我所知,我做得正确:
//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.
我怎样才能正确地做到这一点?
提前致谢。