//
you're reading...
C++, Source Code, Technology

BSTR to char* conversion

I have been trying to find a correct and easy solution for performing a string conversion in C++; a conversion from BSTR to Char*. I need this conversion for writing a wrapper using GSOAP.

I googled but could not find a way to solve the problem. Finally I understood how _bstr_t class did the conversion and managed to find an easier solution defined in comutil.h

The conversion goes like this.

char* resultString = _com_util::ConvertBSTRToString(BSTR stringToConvert);

This works amazingly for me.

Advertisements

Discussion

4 thoughts on “BSTR to char* conversion

  1. Thank you very much for the post.
    I was breaking my head to solve this problem. Could not believe that the solution will be this simpler.
    Keep posting.

    -Suman

    Posted by Suman | October 8, 2009, 4:53 pm
  2. Muito bom , ajudou pra caramba! Obrigado.

    Posted by Joao | April 11, 2010, 5:30 pm
  3. Thanks a lot, for the solution. I found OLE2A variant, but I could not perform it.

    Posted by Voropay | January 10, 2011, 10:21 pm

Trackbacks/Pingbacks

  1. Pingback: BSTR to Char* conversion « Doodle - August 12, 2009

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: