How to stop EnumWindows running infinitely win32

后端 未结 4 1850
囚心锁ツ
囚心锁ツ 2021-01-06 19:37

The code worked all along. Somehow I manage to get Visual C++ Express not hit the break point on the final return statement and it appeared to run for ever.

In the e

4条回答
  •  佛祖请我去吃肉
    2021-01-06 20:26

    Your code works for me, once I removed the wide-character stuff and added #include to get the printf() declaration. What output does it produce on your system?

    The code that works for me is:

    #include 
    #include 
    
    BOOL CALLBACK EnumWindowsProc(HWND hWnd, LPARAM lParam) {
        char buff[255];
    
        if (IsWindowVisible(hWnd)) {
            GetWindowText(hWnd, (LPSTR) buff, 254);
            printf("%s\n", buff);
        }
        return TRUE;
    }
    
    int main() {
        EnumWindows(EnumWindowsProc, 0);
        return 0;
    }
    

提交回复
热议问题