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

    Max size for BSTR?

    Hello!
    I have a problem with a COM component.
    I have a function that returns a BSTR.
    It works very well when the string is about
    22KB and smaller (that is what I have tested).
    But in one case the string is as big as 12MB,
    then the code crash in line 3 below, can
    anybody explain why? is there a max size for
    BSTR/_bstr_t?

    1. STDMETHODIMP X::Func(BSTR * result)
    2. {
    3. _bstr_t bstrBuf((char*)data->OutputBuf);
    4. *result = bstrBuf.copy();
    5. return S_OK;
    6. }


    Thanks and regards
    Rikard



  2. #2
    Join Date
    Jul 2001
    Location
    Mumbai,India
    Posts
    382

    Re: Max size for BSTR?

    It could so be that the OS is not able to allocate that much memory for the string.
    There is no upper limit to the length of a BSTR or any string for that matter. The only constraint on the length of the BSTR is the available memory.
    Please correct me if I'm wrong.

    Regards,
    The Beret.


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