Link to home
Start Free TrialLog in
Avatar of SileNcer
SileNcer

asked on

LPCWSTR -> CString

I'm using a function called NetMessageBufferSend() that requires a LPCWSTR data type.  This string does not seem to be compatible with the CString.  I have created a WCHAR string that seems to work with the funtion, however, I am having problems transfering the data from the CString into the LPCWSTR.

I have tried wsprintf(),strcpy(),and wcscpy(), but none of them seem to work!

Can anyone please show me how to copy the contents of a CString into a WCHAR string(LPCWSTR)?
ASKER CERTIFIED SOLUTION
Avatar of jhance
jhance

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
Avatar of SileNcer
SileNcer

ASKER

The application was all in unicode, so I figured out how to call a pointer to the string.  I am still having problems getting the NetMessageBufferSend() to work.

The program will compile with this code:

LPBYTE message = (LPBYTE)*m_message.GetBuffer(2);
DWORD length = 500;
NetMessageBufferSend(
NULL,                  //server name
(LPCWSTR)*m_domain,      //send to name
(LPCWSTR)*m_username,      //from name
message,            //message
length);            //message length

But it keeps giving me this error:
error LNK2001: unresolved external symbol _NetMessageBufferSend@20

Is there something I'm not doing right with the pointers or something?


Okay! I figured out the problem.  I needed to include netapi32.lib to my project, so it wasn't the pointers after all.