Re: Copy an IStorage interface to an IStream interface for ATTACH_OLE attachments
- From: "na" <na@xxxxxx>
- Date: Tue, 18 Mar 2008 20:19:00 -0500
"Dmitry Streblechenko" <dmitry@xxxxxxxxxxx> wrote in message news:uQCAWcViIHA.1168@xxxxxxxxxxxxxxxxxxxxxxx
IID_IStreamDocfile shoudl do the job if all you want to do is persist the data in a stream.
I appreciate the help...
For this particular attachment (Rich Text email with embedded Bitmap image) I get E_NOINTERFACE.
Thus I try IID_IStorage. Now I want to just stream that to memory. I am trying to implment the
function CreateMemoryStreamFromIStorage shown in the link below and it appears to copy to memory
but I am just not sure if everything is correct or even how to tell at this point. It will be months away
before I care about loading these attachments back into Outlook. For the moment I just want to
stream them out...
http://delphi.newswhat.com/geoxml/forumhistorythread?groupname=borland.public.delphi.oleautomation&messageid=m40ybqr2h8ft$.13ti65ihi7quw.dlg@xxxxxxxxxx
----------------
function CreateMemoryStreamFromIStorage(const Storage: IStorage):
TMemoryStream;
var
LockBytes: ILockBytes;
HGlob: HGLOBAL;
NewStorage: IStorage;
intfStream : IStream;
begin
HGlob := GlobalAlloc(GMEM_MOVEABLE, 0);
try
// TODO : Check if the above memory is leaked.
OleCheck(CreateILockBytesOnHGlobal(HGlob, False, LockBytes));
OleCheck(StgCreateDocfileOnILockBytes(LockBytes,
STGM_CREATE or STGM_READWRITE or STGM_SHARE_EXCLUSIVE{ or
STGM_DIRECT},
0, NewStorage));
OleCheck(Storage.CopyTo(0, nil, nil, NewStorage));
OleCheck(CreateStreamOnHGlobal(HGlob, True, intfStream));
result := StreamFromIStream(intfStream);
result.Seek(0,0);
intfStream := nil;
except
GlobalFree(HGlob);
raise;
end;
end;
--------------------------------
.
- References:
- Prev by Date: Re: Copy an IStorage interface to an IStream interface for ATTACH_OLE attachments
- Next by Date: CDO.Message properties
- Previous by thread: Re: Copy an IStorage interface to an IStream interface for ATTACH_OLE attachments
- Next by thread: Re: Copy an IStorage interface to an IStream interface for ATTACH_OLE attachments
- Index(es):
Relevant Pages
|