• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 502
  • Last Modified:

LPCWSTR to __wchar_t

I am trying to pass a string to a LPCWSTR, but I dont know how to do it. I.E.

LPCWSTR sName[];
NetMessageNameEnum(sName, ...)

I want to have sName[] = \\ServerName, but I do not know how to do it.

I tried LPCWSTR sName[] = "\\ServerName"  not avail

can anyone help me  Thanks ahead of time.

I am  using VC++.net in Visual Studio 03
1 Solution
Jaime OlivaresSoftware ArchitectCommented:
try with
WCHAR sName[] = L"\\ServerName";


LPCWSTR sName = L"\\ServerName";

Notice that LPCWSTR defines a **pointer** to a wide-char string, so it makes no sense to use []
fsharerAuthor Commented:
Thanks, I feel so dumb now, since it was that easy of a solution, I guess that comes with learning
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now