Click to See Complete Forum and Search --> : IStorage,IStream


Tapan
May 18th, 1999, 09:36 PM
dear gurus,
i have been using the IStorage , IStream objects but have encountered exceptions.
i shall give a brief overview of my code

IStorage* pStorage;
HRESULT hr;
hr=StgCreateDocfile(
L"test2.stg",STGM_DIRECT|STGM_WRITE|STGM_SHARE_EXCLUSIVE|STGM_CREATE,NULL,&pStorage);
ULONG cbytes_written=0;
char pt[3]="hi";

IStream* pStream;

pStorage->CreateStream(L"layer1",
STGM_DIRECT | STGM_WRITE|STGM_CREATE ,0,0,&pStream);

pStream->Write(pt,strlen(pt),&cbytes_written);//i get an exception here



i get an exception in the last statement . can anyone tell me why? and how should i go about it?
also, here variable pt is a character , so the 2nd arguement in the Write function is strlen(pt), what if it was integer?
early help appreciated

Peter Hendén
May 28th, 1999, 01:05 PM
Hi.

You didn't check the return from CreateStream(...). You _must_ specify STGM_SHARE_EXCLUSIVE. Or that into your flag word and I'm pretty confident your code will work properly.

Regards,
Peter