1{ 2 This file is part of the Free Pascal run time library. 3 Copyright (c) 1998 by Michael Van Canneyt 4 5 Win part of pipe stream. 6 7 See the file COPYING.FPC, included in this distribution, 8 for details about the copyright. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 14 **********************************************************************} 15 16uses windows; 17 18Const piInheritablePipe : TSecurityAttributes = ( 19 nlength:SizeOF(TSecurityAttributes); 20 lpSecurityDescriptor:Nil; 21 Binherithandle:True); 22 piNonInheritablePipe : TSecurityAttributes = ( 23 nlength:SizeOF(TSecurityAttributes); 24 lpSecurityDescriptor:Nil; 25 Binherithandle:False); 26 27 28 PipeBufSize = 1024; 29 30 31Function CreatePipeHandles (Var Inhandle,OutHandle : THandle; APipeBufferSize : Cardinal = PipeBufSize) : Boolean; 32 33begin 34 Result := CreatePipe (@Inhandle,@OutHandle,@piNonInheritablePipe,APipeBufferSize); 35end; 36 37 38Function TInputPipeStream.GetNumBytesAvailable: DWord; 39begin 40 if not PeekNamedPipe(Handle, nil, 0, nil, @Result, nil) then 41 Result := 0; 42end; 43 44function TInputPipeStream.GetPosition: Int64; 45begin 46 Result:=FPos; 47end; 48 49procedure TInputPipeStream.InvalidSeek; 50begin 51 Raise EPipeSeek.Create (ENoSeekMsg); 52end; 53 54procedure PipeClose (const FHandle: THandle); inline; 55begin 56 FileClose(FHandle); 57end; 58