mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-29 11:39:23 +02:00
* TOleStream + TProxystream (Mantis 8376)
git-svn-id: trunk@13984 -
This commit is contained in:
parent
4a7f3de318
commit
b5e361a4cb
@ -46,6 +46,10 @@ unit comobj;
|
|||||||
|
|
||||||
EOleRegistrationError = class(EOleError);
|
EOleRegistrationError = class(EOleError);
|
||||||
|
|
||||||
|
TOleStream = Class(TProxyStream)
|
||||||
|
procedure Check(err:integer);override;
|
||||||
|
end;
|
||||||
|
|
||||||
TComServerObject = class(TObject)
|
TComServerObject = class(TObject)
|
||||||
protected
|
protected
|
||||||
function CountObject(Created: Boolean): Integer; virtual; abstract;
|
function CountObject(Created: Boolean): Integer; virtual; abstract;
|
||||||
@ -1279,6 +1283,11 @@ HKCR
|
|||||||
RunError(217);
|
RunError(217);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TOleStream.Check(err:integer);
|
||||||
|
begin
|
||||||
|
OleCheck(err);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
const
|
const
|
||||||
Initialized : boolean = false;
|
Initialized : boolean = false;
|
||||||
|
@ -703,6 +703,7 @@ type
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
|
|
||||||
{ TStream abstract class }
|
{ TStream abstract class }
|
||||||
|
|
||||||
@ -745,6 +746,19 @@ type
|
|||||||
property Size: Int64 read GetSize write SetSize64;
|
property Size: Int64 read GetSize write SetSize64;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
TProxyStream = class(TStream)
|
||||||
|
private
|
||||||
|
FStream: IStream;
|
||||||
|
protected
|
||||||
|
function GetIStream: IStream;
|
||||||
|
public
|
||||||
|
constructor Create(const Stream: IStream);
|
||||||
|
function Read(var Buffer; Count: Longint): Longint; override;
|
||||||
|
function Write(const Buffer; Count: Longint): Longint; override;
|
||||||
|
function Seek(Offset: Longint; Origin: Word): Longint; override;
|
||||||
|
procedure Check(err:longint); virtual;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TOwnerStream }
|
{ TOwnerStream }
|
||||||
TOwnerStream = Class(TStream)
|
TOwnerStream = Class(TStream)
|
||||||
Protected
|
Protected
|
||||||
|
@ -896,4 +896,41 @@ function TStreamAdapter.Clone(out stm: IStream): HResult; stdcall;
|
|||||||
begin
|
begin
|
||||||
runerror(217);
|
runerror(217);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
constructor TProxyStream.Create(const Stream: IStream);
|
||||||
|
begin
|
||||||
|
FStream := Stream;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TProxyStream.Read(var Buffer; Count: Longint): Longint;
|
||||||
|
begin
|
||||||
|
Check(FStream.Read(@Buffer, Count, @Result));
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TProxyStream.Seek(Offset: Longint; Origin: Word): Longint;
|
||||||
|
var
|
||||||
|
Pos: Int64;
|
||||||
|
begin
|
||||||
|
Check(FStream.Seek(Offset, Origin, Pos));
|
||||||
|
Result := Pos;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TProxyStream.Write(const Buffer; Count: Longint): Longint;
|
||||||
|
begin
|
||||||
|
Check(FStream.Write(@Buffer, Count, @Result));
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TProxyStream.GetIStream: IStream;
|
||||||
|
begin
|
||||||
|
Result := FStream;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TProxyStream.Check(err:integer);
|
||||||
|
var e : EInOutError;
|
||||||
|
begin
|
||||||
|
e:= EInOutError.Create('Proxystream.Check');
|
||||||
|
e.Errorcode:=err;
|
||||||
|
raise e;
|
||||||
|
end;
|
||||||
|
|
||||||
{$warnings on}
|
{$warnings on}
|
||||||
|
Loading…
Reference in New Issue
Block a user