Share via


How do you convert an std::wstring into a LPCWSTR?

Question

Saturday, November 5, 2011 4:11 AM

bool OpenPort(const std::wstring PortName, HANDLE& hCOM)
{
    hCOM = CreateFileW(PortName,  // LPCWSTR lpFileName
                                  /* ... */ );
}

Note that this should all be unicode. I have tried everything and I can't seem to figure it out. What do I put for the first parameter of CreateFileW?

All replies (1)

Saturday, November 5, 2011 4:59 AM âś…Answered | 1 vote

Dwigt wrote:

[code]
bool OpenPort(const std::wstring PortName, HANDLE& hCOM)
{
   hCOM = CreateFileW(PortName,  // LPCWSTR lpFileName

PortName.c_str()

Igor Tandetnik