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

  • Home
  • SEARCH
  • 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 48989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T16:21:59+00:00 2026-05-10T16:21:59+00:00

When maintaining a COM interface should an empty BSTR be treated the same way

  • 0

When maintaining a COM interface should an empty BSTR be treated the same way as NULL? In other words should these two function calls produce the same result?

 // Empty BSTR  CComBSTR empty(L''); // Or SysAllocString(L'')  someObj->Foo(empty);   // NULL BSTR  someObj->Foo(NULL);      
  • 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. 2026-05-10T16:22:00+00:00Added an answer on May 10, 2026 at 4:22 pm

    Yes – a NULL BSTR is the same as an empty one. I remember we had all sorts of bugs that were uncovered when we switched from VS6 to 2003 – the CComBSTR class had a change to the default constructor that allocated it using NULL rather than an empty string. This happens when you for example treat a BSTR as a regular C style string and pass it to some function like strlen, or try to initialise a std::string with it.

    Eric Lippert discusses BSTR’s in great detail in Eric’s Complete Guide To BSTR Semantics:

    Let me list the differences first and then discuss each point in excruciating detail.

    1. A BSTR must have identical semantics for NULL and for "". A PWSZ frequently has different semantics for those.

    2. A BSTR must be allocated and freed with the SysAlloc* family of functions. A PWSZ can be an automatic-storage buffer from the stack or allocated with malloc, new, LocalAlloc or any other memory allocator.

    3. A BSTR is of fixed length. A PWSZ may be of any length, limited only by the amount of valid memory in its buffer.

    4. A BSTR always points to the first valid character in the buffer. A PWSZ may be a pointer to the middle or end of a string buffer.

    5. When allocating an n-byte BSTR you have room for n/2 wide characters. When you allocate n bytes for a PWSZ you can store n / 2 – 1 characters — you have to leave room for the null.

    6. A BSTR may contain any Unicode data including the zero character. A PWSZ never contains the zero character except as an end-of-string marker. Both a BSTR and a PWSZ always have a zero character after their last valid character, but in a BSTR a valid character may be a zero character.

    7. A BSTR may actually contain an odd number of bytes — it may be used for moving binary data around. A PWSZ is almost always an even number of bytes and used only for storing Unicode strings.

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

Sidebar

Ask A Question

Stats

  • Questions 108k
  • Answers 108k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer By your script, if you can get what you want… May 11, 2026 at 9:19 pm
  • Editorial Team
    Editorial Team added an answer The NSTokenField invokes the controlTextDidChange: and the controlTextDidEndEditing: notifications; change… May 11, 2026 at 9:19 pm
  • Editorial Team
    Editorial Team added an answer You might want to check out the Microsoft Speech API… May 11, 2026 at 9:19 pm

Related Questions

This past summer I was developing a basic ASP.NET/SQL Server CRUD app, and unit
In our processing software we are moving from one version of an external assembly
I have an application that has several objects (about 50 so far, but growing).
(Updated: I've moved this over to ServerFault ) I'm responsible for maintaining a list

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.