Interprocess communication via pipes, Memory I/O

Programming applications for MS Windows
Post Reply
Administrator
Site Admin
Posts: 83
Joined: 26-Feb-2014, 17:54

Interprocess communication via pipes, Memory I/O

Post by Administrator » 17-Jul-2024, 21:36

Code: Select all

HANDLE               hReadPipe;
HANDLE               hWritePipe;
CreatePipe(&hReadPipe, &hWritePipe , 0, 0);
WriteFile(hWritePipe, "hello", 5, 0, 0);

int sz = GetFileSize(hReadPipe, 0);
assert(sz == 5);
char out[5];
ReadFile(hReadPipe, out, 5, 0,0);
It is possible to use fread/fwrite after getting FILE* pointer or OS fileno().
See: _open_osfhandle() and _get_osfhandle() and _fdopen() to get FILE*.

Post Reply