I need to convert a BSTR buffer (that contains wchar data) to a straight char*.

How can I do that?

I only found that info so far:


but it covers only CComBSTR types. I'm not sure how CComBSTR and BSTR relate.


Ok, got it.

If anybody is interested, this seems to work:

int len = (int) SysStringLen(exMsg);
  char *cvt;   

  cvt = (char *) malloc(1+len);
  WideCharToMultiByte( CP_ACP, 0, exMsg, -1, cvt, len, NULL, NULL );
  cvt[len] = '\0';