Home > Blockchain >  fail to wcout wchar[] which from GetWindowText();
fail to wcout wchar[] which from GetWindowText();

Time:06-05

while(TRUE){
    HWND window = GetForegroundWindow();
    WCHAR str[300] ;
    ZeroMemory(str, sizeof(str));
    GetWindowTextW(window,str,299);
    wcout<<L"11"<<endl;
    wcout<<str;
    wcout<<L"22"<<endl;
    Sleep(1000);
}

this code will output "11",and then stuck. When I try to use charcout and GetWindowTextA,this loop can run and output English character normal.
With single step debug, the loop still run actually. But don't output anything. And str show window's title normal.

CodePudding user response:

OK ! Just need to set locale that I forget.

wcout.imbue(locale("your locale"));
  • Related