简体   繁体   English

如何正确获取Unicode窗口标题

[英]How to get Unicode window title correctly

I create Win32 console application that does a simple task: it enumerates captions of all windows. 我创建了Win32控制台应用程序,该应用程序执行简单的任务:它枚举所有窗口的标题。 Everything works well except one little point – “non-English” titles are returned as “GDI+ Window”. 除了一点点以外,其他所有内容都运行良好-“非英语”标题将作为“ GDI +窗口”返回。

I do not know how to retrieve such captions in a right way. 我不知道如何以正确的方式检索此类字幕。

For example, I have window with the caption: Hello Мир. 例如,我有一个带标题的窗口:HelloМир。 However, GetWindowTextW returns “Hello GDI+ Window” 但是,GetWindowTextW返回“ Hello GDI + Window”

There is my program code (simplified): 有我的程序代码(简体):


    BOOL CALLBACK nextWindow ( HWND window, LPARAM param )
    {
        int i = GetWindowTextW ( ... );
        wprintf ( ... );
        return true;
    }

    int main ()
    {
        WNDENUMPROC func = &nextWindow;
        LPARAM someValue = 0;

        BOOL result = EnumWindows ( func, someValue );
        return 0;
    }

There is my Project Settings: Visual Studio Project Settings 有我的项目设置: Visual Studio项目设置

Thank you! 谢谢!

Thank you guys, you were most helpful! 谢谢大家,您最有帮助!

In my case, I just need to change translation mode using the following code: 就我而言,我只需要使用以下代码来更改翻译模式:

_setmode ( _fileno ( stdout ), _O_U8TEXT );

See more details in article by Michael S. Kaplan . 请参阅Michael S. Kaplan的文章中的更多详细信息。

Problem solved. 问题解决了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM