|
-
September 11th, 2016, 02:12 PM
#3
Re: WNetAddConnection2 returns error 1200
 Originally Posted by NastyaG
What is my mistake? How can I solve this problem?
Your mistake is that you think that casting ANSI string to LPWSTR would miraculously turn it to Unicode string. But the trick just won't work, because what you do is making compiler believe the string is wide string. While it's realy not.
Quite a standard mistake for beginner who does not understand C pointers.
And yes, about how to solve... You either provide wide string literal (this is what 2kaud advised), or explicitly tranlate string to the required encoding. E.g. using CString class:
Code:
CString name = "folder";
nr.lpLocalName = name.GetBuffer();
Oh! And you'd better get to habit of zeroing structures you're not going to initialize in every member.
Code:
NETRESOURCE nr = {0};
Just to avoid passing garbage.
Last edited by Igor Vartanov; September 11th, 2016 at 02:45 PM.
Best regards,
Igor
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|