【发布时间】:2012-03-25 18:14:33
【问题描述】:
可能重复:
C++ std::string conversion problem on Windows
How to convert std::string to LPCSTR?
我想将一个窗口 ( WM_SETTEXT ) 重命名为其他名称。有一个包含新窗口名称的 std::string 。我需要将 std::string 转换为“LPCTSTR”,这是因为 SendMessage 需要“LPCTSTR”中的名称。
我无法让它工作,有人可以帮我将字符串转换为 LPCTSTR 吗?
【问题讨论】:
-
C++ std::string conversion problem on Windows 或 stackoverflow.com/questions/1200188/… 的可能重复项,或此页面上的许多其他“相关”问题。
-
你的程序是用Unicode还是ANSI模式编译的?这会影响
LPCTSTR的真正含义。 -
使用 SetWindowTextA() 是快速修复。
-
哦@Hans,不要鼓励 ANSI 文本的邪恶! ;-)