convert CString to WCHAR
-
Hi all, I want to convert CString to WCHAR; i have done this:-
WCHAR wsz[MAX_PATH];
CString szLinkName = _T("Test Mail");
MultiByteToWideChar(CP_ACP, 0, (LPCSTR)(LPCTSTR)szLinkName, -1,
wsz, MAX_PATH);but i only get "T" in wsz i.e first element.... I am working in VC2005 Can anybody help me in this... Thanks in advance
-
Hi all, I want to convert CString to WCHAR; i have done this:-
WCHAR wsz[MAX_PATH];
CString szLinkName = _T("Test Mail");
MultiByteToWideChar(CP_ACP, 0, (LPCSTR)(LPCTSTR)szLinkName, -1,
wsz, MAX_PATH);but i only get "T" in wsz i.e first element.... I am working in VC2005 Can anybody help me in this... Thanks in advance
This is the Gabababazillionth time this question is asked. Please learn to use Google[^].
Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP
-
Hi all, I want to convert CString to WCHAR; i have done this:-
WCHAR wsz[MAX_PATH];
CString szLinkName = _T("Test Mail");
MultiByteToWideChar(CP_ACP, 0, (LPCSTR)(LPCTSTR)szLinkName, -1,
wsz, MAX_PATH);but i only get "T" in wsz i.e first element.... I am working in VC2005 Can anybody help me in this... Thanks in advance
neha.agarwal27 wrote:
MultiByteToWideChar(CP_ACP, 0, (LPCSTR)(LPCTSTR)szLinkName, -1, wsz, MAX_PATH);
how and why do you decided to use MultiByteToWideChar here?
-
Hi all, I want to convert CString to WCHAR; i have done this:-
WCHAR wsz[MAX_PATH];
CString szLinkName = _T("Test Mail");
MultiByteToWideChar(CP_ACP, 0, (LPCSTR)(LPCTSTR)szLinkName, -1,
wsz, MAX_PATH);but i only get "T" in wsz i.e first element.... I am working in VC2005 Can anybody help me in this... Thanks in advance
Why do it the hard way when there are macros in ATL to do it for you. #include void MyFunc(WCHAR* s) { USES_CONVERSION; CString str = W2T(s); } Just make sure you don't use W2T() in a loop since it allocate memory from the stack. then use W2T_EX instead and USES_CONVERSION_EX;
-
Hi all, I want to convert CString to WCHAR; i have done this:-
WCHAR wsz[MAX_PATH];
CString szLinkName = _T("Test Mail");
MultiByteToWideChar(CP_ACP, 0, (LPCSTR)(LPCTSTR)szLinkName, -1,
wsz, MAX_PATH);but i only get "T" in wsz i.e first element.... I am working in VC2005 Can anybody help me in this... Thanks in advance
neha.agarwal27 wrote:
but i only get "T" in wsz i.e first element....
How are you verifying this?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne