简体   繁体   中英

How to get Unicode window title correctly

I create Win32 console application that does a simple task: it enumerates captions of all windows. Everything works well except one little point – “non-English” titles are returned as “GDI+ Window”.

I do not know how to retrieve such captions in a right way.

For example, I have window with the caption: Hello Мир. However, GetWindowTextW returns “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

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 .

Problem solved.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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