How to Convert char* to LPWSTR in VC++ ?
LPNETRESOURCEW nr = NULL;
memset(&nr, 0, sizeof (NETRESOURCE));
nr->lpLocalName = strDriveLetter.GetBuffer(strDriveLetter.GetLength()); // this line giving me error "Cannot Convert char* to LPWSTR"
Any help is appreciated.
Thanks.
Use MultiByteToWideChar
function;
const char* msg = "foobarbaz";
int len = strlen(msg) + 1;
wchar_t *w_msg = new wchar_t[len];
memset(w_msg, 0, len);
MultiByteToWideChar(CP_ACP, NULL, msg, -1, w_msg, len);
memset(&nr, 0, sizeof (NETRESOURCE));
here nr is a NULL pointer. This is not correct. You should have nr point to a valid memory first by either using explicit allocation like new
or on allocate on stack.