Page 1 of 1

Interprocess communication via pipes, Memory I/O

Posted: 17-Jul-2024, 21:36
by Administrator

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*.