CString to LPCWSTR conversion ???
-
does anybody know how to convert from "CString" to "LPCWSTR" ? i am using BITS in my program and the "IBackgroundCopyJob::AddFile" function takes input only as HRESULT AddFile(LPCWSTR pRemoteName,LPCWSTR pLocalName); i wish to pass CString taken from the user interface to the BITS function.:) didn't get much help from MSDN :((
-
does anybody know how to convert from "CString" to "LPCWSTR" ? i am using BITS in my program and the "IBackgroundCopyJob::AddFile" function takes input only as HRESULT AddFile(LPCWSTR pRemoteName,LPCWSTR pLocalName); i wish to pass CString taken from the user interface to the BITS function.:) didn't get much help from MSDN :((
I found MSDN to be quite informative.[^] Don't forget to call ReleaseBuffer when you finish with it. I take it back, you're trying to create a wide string. Try this[^] instead. A _bstr_t will convert between narrow and wide strings for you ( by using these macros ), but is not of much use otherwise. Christian Graus - Microsoft MVP - C++
-
does anybody know how to convert from "CString" to "LPCWSTR" ? i am using BITS in my program and the "IBackgroundCopyJob::AddFile" function takes input only as HRESULT AddFile(LPCWSTR pRemoteName,LPCWSTR pLocalName); i wish to pass CString taken from the user interface to the BITS function.:) didn't get much help from MSDN :((
Look at this http://www.codeproject.com/script/comments/forums.asp?msg=1124974&forumid=1647#xx1124974xx[^]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta
-
does anybody know how to convert from "CString" to "LPCWSTR" ? i am using BITS in my program and the "IBackgroundCopyJob::AddFile" function takes input only as HRESULT AddFile(LPCWSTR pRemoteName,LPCWSTR pLocalName); i wish to pass CString taken from the user interface to the BITS function.:) didn't get much help from MSDN :((
The easiest way would be to compile you program to use UNICODE strings. In Project - Settings - C/C++ : Preprocessor definitions make sure _UNICODE is defined and not _ANSI or _MBCS. This will make CString use wide chars and allow an auto cast down to LPCWSTR. ...cmk Save the whales - collect the whole set