* TOleStream + TProxystream (Mantis 8376)

git-svn-id: trunk@13984 -
This commit is contained in:
marco 2009-10-30 18:27:26 +00:00
parent 4a7f3de318
commit b5e361a4cb
3 changed files with 60 additions and 0 deletions

View File

@ -46,6 +46,10 @@ unit comobj;
EOleRegistrationError = class(EOleError);
TOleStream = Class(TProxyStream)
procedure Check(err:integer);override;
end;
TComServerObject = class(TObject)
protected
function CountObject(Created: Boolean): Integer; virtual; abstract;
@ -1279,6 +1283,11 @@ HKCR
RunError(217);
end;
procedure TOleStream.Check(err:integer);
begin
OleCheck(err);
end;
const
Initialized : boolean = false;

View File

@ -703,6 +703,7 @@ type
end;
{$endif}
{ TStream abstract class }
@ -745,6 +746,19 @@ type
property Size: Int64 read GetSize write SetSize64;
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 = Class(TStream)
Protected

View File

@ -896,4 +896,41 @@ function TStreamAdapter.Clone(out stm: IStream): HResult; stdcall;
begin
runerror(217);
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}