goodami
asked on
How to convert BSTR to char*
How to convert BSTR to char*
or you can use
myFunc(BSTR bstr)
{
USES_CONVERSION;
char* pOut = OLE2A(bstr);
}
I suggest you read topic on conversion macros (Microsoft TN059) , there are some points you need to now about memory menagement, to use them correctly.
Hope it helps.
myFunc(BSTR bstr)
{
USES_CONVERSION;
char* pOut = OLE2A(bstr);
}
I suggest you read topic on conversion macros (Microsoft TN059) , there are some points you need to now about memory menagement, to use them correctly.
Hope it helps.
mblat,
Welcome to Experts Exchange!
It's common practice here to use the Comment button, rather than the Answer button, when responding to a question, unless you are absolutely 100 per cent certain that your response is the ONLY complete and accurate solution to a problem, AND that your response doesn't duplicate or paraphrase someone else's response. Because your suggestion does not fulfill those two criteria, I've rejected your answer.
EE is a collaborative website; a major part of what makes it work is that an Asker can get a variety of suggestions. When you Propose an Answer, the question gets Locked, which makes it less likely for that collaboration to occur.
The Asker sees a button which says "Accept This Comment As Answer" -- so if he/she chooses your response, you'll get the points.
For more information, there are tips at the bottom of the page, as well as the link suggested by jhance.
Again, welcome aboard,
Netminder
Community Support Moderator
Welcome to Experts Exchange!
It's common practice here to use the Comment button, rather than the Answer button, when responding to a question, unless you are absolutely 100 per cent certain that your response is the ONLY complete and accurate solution to a problem, AND that your response doesn't duplicate or paraphrase someone else's response. Because your suggestion does not fulfill those two criteria, I've rejected your answer.
EE is a collaborative website; a major part of what makes it work is that an Asker can get a variety of suggestions. When you Propose an Answer, the question gets Locked, which makes it less likely for that collaboration to occur.
The Asker sees a button which says "Accept This Comment As Answer" -- so if he/she chooses your response, you'll get the points.
For more information, there are tips at the bottom of the page, as well as the link suggested by jhance.
Again, welcome aboard,
Netminder
Community Support Moderator
#include <comutil.h>
char *WorkCharString = _com_util::ConvertBSTRToSt ring(InBST R);
char *WorkCharString = _com_util::ConvertBSTRToSt
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
...
// Get the BSTR into a _bstr_t class
_bstr_t mybstr = new _bstr_t(YOUR_BSTR_VAR, false);
// Use the (char *) operator from _bstr_t to get this into
// a const char *
const char *lpszStr = (char *)mybstr;
// Do your char * string thing..
// Delete the _bstr_t
delete mybstr;