Thanks Chris, Kyley & David,

  TstreamAdapter was just what the doctor ordered.

Cheers
Ben
 
 

-----Original Message-----
From: Chris Milham [mailto:[EMAIL PROTECTED]] 
Sent: Friday, 27 September 2002 11:54 a.m.
To: Multiple recipients of list delphi
Subject: RE: [DUG]: A COM interface for a TStream object

Hi,

This doesn't answer your question but may help you..
Have you looked at TStreamAdapter which "Implements OLE IStream on VCL
TStream"?
It's in the 'classes' unit.
Could save you a lot of time :)

Chris

> -----Original Message-----
> From: Vaughan, Benjamin Carl [mailto:[EMAIL PROTECTED]]
> Sent: Friday, 27 September 2002 11:48 a.m.
> To: Multiple recipients of list delphi
> Subject: [DUG]: A COM interface for a TStream object
> 
> 
> Hi All,
> 
> I am attempting to write a COM interface for the TStream 
> object, but I am
> currently running into a problem. The current issue that I am 
> facing is with
> my CopyFrom method which I have pasted below. 
> 
> The problem that I have is that when the method completes it raises an
> access violation (basically right on the 'end;' line). I can however
> confirm  that the copying of the stream does occur successfully. 
> 
> If anyone has any ideas on what is wrong with my CopyFrom 
> method any help is
> appreciated. I also found if I don't call the 
> "Source.ReadBuffer(Buffer^, N);" line the error will not occur.
> 
> Ben Vaughan
> ================================
> Systems Architect
> Business Education Online
> University of Auckland
> ================================
> Old Choral Hall, 7 Symonds St, Auckland
> (P) +64 9 3737599 x2514 (F) +64 9 3737430
> 
> 
> function TMyStream.CopyFrom(const Source: IMyStream; Count: Integer):
> Integer;
> const
>   MaxBufSize = $F000;
> var
>   BufSize, N: Integer;
>   Buffer: POleVariant1;
> begin
>   if Count = 0 then
>   begin
>     Source.Position := 0;
>     Count := Source.Size;
>   end;
>   Result := Count;
>   if Count > MaxBufSize then BufSize := MaxBufSize else 
> BufSize := Count;
>   GetMem(Buffer, BufSize);
>   try
>     while Count <> 0 do
>     begin
>       if Count > BufSize then N := BufSize else N := Count;
>       Source.ReadBuffer(Buffer^, N);
>       WriteBuffer(Buffer^, N);
>       Dec(Count, N);
>     end;
>   finally
>     FreeMem(Buffer, BufSize);
>   end;
> end;
> 
> procedure TMyStream.ReadBuffer(var Buffer: OleVariant; Count: 
> Integer);
> begin
>   fStream.ReadBuffer(Buffer,Count);
> end;
> 
> procedure TMyStream.WriteBuffer(var Buffer: OleVariant; 
> Count: Integer);
> begin
>   fStream.WriteBuffer(Buffer,Count);
> end;
> 
> --------------------------------------------------------------
> -------------
>     New Zealand Delphi Users group - Delphi List - 
> [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz
> To UnSub, send email to: [EMAIL PROTECTED] 
> with body of "unsubscribe delphi"
> Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/
> 
---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/
---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

Reply via email to