title: How to use BSTR*
body: <p>I have an <code>out</code> value as BSTR* for an interface in a C++ COM dll. And I am returning this to a C# .Net client. In my C++ function I have to assign different values according to a diff condition.</p>
  
  <p>For example:</p>
  
  <pre><code>If my function is fun(BSTR* outval)
  {
     // I have to assign a default value to it such as:
     *outval = SysAllocSTring(L"N");
  
     Then I will check for some DB conditions
     { 
       // And I have to allocate it according to that.
       // Do I need to again calling SysAllocString?
       eq.*outval = SySAllocString(DBVlaue);
     }
  }
  </code></pre>
  
  <p>What happens if I call SysAllocSTring two times to the same BSTR? What is the best way to handle this?</p>