CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 1999
    Posts
    19

    IStorage,IStream

    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








  2. #2
    Join Date
    May 1999
    Posts
    17

    Re: IStorage,IStream

    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



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured