Converting TCHAR to string in C++

后端 未结 5 972
-上瘾入骨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:32

    If you want the path in chars, you should call GetModuleFilenameA. That function takes LPSTR instead of LPTSTR.

    Note that almost all Win32 functions that take or return strings have two version, one ending in A (ANSI?) and the other ending in W (wide).

提交回复
热议问题