Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting BSTR's to char *

Status
Not open for further replies.

MarkRuse

Programmer
Aug 11, 1999
29
GB
Hi,<br>
<br>
I am currently trying to write a ATL object which takes in a BSTR and convert it to a char *. I then put this char * into a Roguewave RWCString object to create a string object.<br>
<br>
fn(BSTR *Source)<br>
{<br>
unsigned DataLen;<br>
BSTR BstrData;<br>
<br>
RWCString str_one((char*) *Source);<br>
DataLen = str_one.length();<br>
SysReAllocString (Source, (BSTR) str_one.data());<br>
}<br>
<br>
This code would take in the Source string, allow me to change it, then return it back to the calling code.<br>
<br>
This worked under NT3.51, but now on NT4 it seems as if the BSTR is a Multibyte Character set.<br>
<br>
Does anybody know how I can simply take in a BSTR convert it to a char *, work with it, then convert it back to a BSTR for returning to the calling code ?<br>
<br>
I have spent all day with this, and I am about to pull my hair out!<br>
<br>

 
Hi MarkRuse!<br>
<br>
What are the chances that the BSTR is in Unicode?<br>
<br>
So, you'd cast it to a char*, then run it through something like the WideCharToMultiByte() function before assigning it to the RWCString variable.<br>
<br>
Chip H.<br>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top