Link to home
Start Free TrialLog in
Avatar of ptrennum
ptrennum

asked on

How to convert a CString to a LPCWSTR

I have a Cstring and I need to convert it to a LPCWSTR.  How can this be done?

PT
Avatar of ptrennum
ptrennum

ASKER

I actually need to convert it to a wchar_t - Sorry about that, the conversion for the CString would be:

(LPCWSTR)(cstring)
ok increased points on this one asI'm loooking for a relatively quick response
PT
Avatar of jkr
I'd use

CString strTest = "Test";
wchar_t* pwsz = new wchar_t[strTest.GetLength() + 1];

mbstowcs(awc, (LPCTSTR) strTest, strTest.GetLength() + 1);
The problem I'm having is with the privilege code from yesterday.  the pwszAccount is asking to be converted from a wchar_t* to a LPTSTR and when I do the conversion i only get the first character back from the original string.

PT
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You're the man!

Thanks again

PT
Thanx :o)