Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7171133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:21:09+00:00 2026-05-28T15:21:09+00:00

The MSDN article just says: Return Value S_OK on success, or any standard HRESULT

  • 0

The MSDN article just says:

Return Value

S_OK on success, or any standard HRESULT error value.

However, my guess is that E_OUTOFMEMORY is the only feasible error return since NULL is valid input and an invalid memory location will just throw an access violation (hopefully).

So. Are there any other possible HRESULTS from this method?

Note: The following all return S_OK:

CComBSTR bstr;
bstr.AssignBSTR(NULL);
bstr.AssignBSTR(SysAllocString(L""));   //clearly a leak, abbreviated example...
bstr.AssignBSTR(SysAllocString(L"HI"));

Bottom Line: Is the following good practice (and why do I often see other implementations?):

class foo {
public:
  STDMETHOD(put_Bar)(BSTR p);
private:
  CComBSTR m_bstrBar
};

STDMETHODIMP foo::put_Bar( BSTR p)
{
    return m_bstrBar.AssignBSTR(p);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T15:21:10+00:00Added an answer on May 28, 2026 at 3:21 pm

    Yes, E_OUTOFMEMORY is it in this very specific case. You can see the source code in vc/atlmfc/include/atlcomcli.h

    This is otherwise similar to asking for exception specifications. Doesn’t work, COM methods can return any error code. Weird ones too when the call is marshaled out of process or across a network.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just stumbled on this article on MSDN that says a path can be
I just read a MSDN article, Synchronization and Multiprocessor Issues , that addresses memory
As per this MSDN article: W3C Extended Log File Format (IIS 6.0) It says
I've read the MSDN article about the layouts pass, that states: When a node
This article on MSDN states that you can use as many try catch blocks
I just got done following the steps in this MSDN article on creating a
I just saw this code #pragma warning disable 659, 660, 661 MSDN article is
Once I read an MSDN article that encouraged the following programming paradigm (its not
From an MSDN article on the subject, we can see that we create a
Just reading the msdn article on overriding equality operators here The following snippet confuses

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.