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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LPSTR to BSTR conversion

Status
Not open for further replies.

jerasi

Programmer
Jun 19, 2000
141
CA
How do i convert from LPSTR to BSTR?

Thank you.
 
below are some methods on using char* to wchar_t. BSTR is the same as wchar_t* or unsigned short*

#include<comdef.h>//for _bstr_t
#include<iostream>

using namespace std;//for iostream
int main()
{
BSTR bx = L&quot;Hello &quot;;
char* cx = &quot;world&quot;
_bstr_t x = bx;
bx += cx;
wcout<<bx;
cout<<cx<<endl;
wcout<<(BSTR)x<<endl;
cout<<(char*)x<<endl;
BSTR by = (BSTR)x;
char cy = (char*)x;
wcout<<by<<endl;
cout<<cy<<endl;
cout<<&quot;there was shown some tehnics on using ATL :)&quot;<<endl;
return 0;
} John Fill
1c.bmp


ivfmd@mail.md
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top