Converting TCHAR to string in C++

后端 未结 5 969
-上瘾入骨i
-上瘾入骨i 2020-12-20 11:24

I\'m trying to convert a TCHAR to a string as in:

std::string mypath;
TCHAR path[MAX_PATH];
GetModuleFileName( NULL, path, MAX_PATH );

I ne

5条回答
  •  天涯浪人
    2020-12-20 11:55

    Hi this is a late answer but I have an idea.

    {wstring test = User;
     std::wcout << test << std::endl;
     string test2(test.begin(), test.end());
     std::cout << test2 << std::endl;}
    

    User is in this example the username as a TCHAR. Now I can use the name as a string or wstring. This is the easiest way to convert the TCHAR to a string.

提交回复
热议问题