LPCWSTR to __wchar_t

Posted on 2005-05-03
Last Modified: 2008-03-03
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 in Visual Studio 03
Question by:fsharer
    LVL 55

    Accepted Solution

    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 []

    Author Comment

    Thanks, I feel so dumb now, since it was that easy of a solution, I guess that comes with learning

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
    In Easy String Encryption Using CryptoAPI in C++ ( I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    This video discusses moving either the default database or any database to a new volume.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now