title: C++: Convert wchar_t* to BSTR?
body: <p>I'm trying to convert a <code>wchar_t *</code> to <code>BSTR</code>. </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;atlstr.h&gt;
  
  using namespace std;
  
  int main()
  {
      wchar_t* pwsz = L"foo"; 
  
      BSTR bstr(pwsz);
  
      cout &lt;&lt; SysStringLen(bstr) &lt;&lt; endl;
  
      getchar();
  }
  </code></pre>
  
  <p>This prints <code>0</code>, which is less than what I'd hoped. What is the correct way to do this conversion?</p>