program pipes APPTYPE CONSOLE uses Windows SysUtils Zlib function gzop

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
program pipes;
{$APPTYPE CONSOLE}
uses
Windows,
SysUtils;
// Zlib
function gzopen(path, mode: PAnsiChar): Pointer; cdecl; external 'zlib1.dll';
function gzdopen(fd: Cardinal; mode: PAnsiChar): Pointer; cdecl; external 'zlib1.dll';
function gzread(gzFile, buf: Pointer; len: Cardinal): Integer; cdecl; external 'zlib1.dll';
function gzeof(gzFile: Pointer): Integer; cdecl; external 'zlib1.dll';
function gzclose(gzFile: Pointer): Integer; cdecl; external 'zlib1.dll';
function gzwrite(gzFile: Pointer; buf: PAnsiChar; len: Integer): Integer; cdecl; external 'zlib1.dll';
function _pipe(phandles: Pointer; psize: Integer; textmode: Integer): Integer; cdecl; external 'msvcrt.dll';
var
hRead: Cardinal;
hWrite: Cardinal;
hGz: Pointer;
gzBuf: array [1..4096] of Char;
nRead, nWrite: Cardinal;
Output: file;
SecAttr: SECURITY_ATTRIBUTES;
hpipe: array[0..1] of integer;
begin
_pipe(@hpipe[0], 256, $8000);
hGz := gzdopen(hpipe[1], 'wb');
nWrite := gzwrite(hGz, 'Проверка', 8);
WriteLn(Format('%d bytes written', [nWrite]));
gzclose(hGz);
end.