Data Conversion

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello Everyone,

I am trying to display BSTR data in a message box,
but looks like messagebox does not support BSTR data,
can any one tell me how to acomplish this?

I would really appreciate your help

Thank you
 
It has been awhile, but, if I remember correctly, BSTR has a four byte header
(Int64) that tells the length of the string. After that, you should be able
to pull the text from the rest of the BSTR. Grab the bytes and ignore the
first 4. For the rest, turn into characters (code written on the fly, so
tailor to your use):

char[] charBuffer = new char[bstr.Length - 4];

for(int i=4;i<bstr.Length;i++)
{
charBuffer = (char) bstr;
}

StringBuilder sb = new StringBuilder();
sb.Append(charBuffer);

string outputString = sb.ToString();

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
 
Back
Top