Hi,

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:

http://msdn.microsoft.com/en-us/library/ms235631(VS.80).aspx

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

Thanks.

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';
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.