简体   繁体   中英

C++ - See if an hWnd window is responding or not?

I'm making an application to change some information around in another window. The problem is, Sometimes it causes the window to "Not Respond."

So my question is, Using C++, How do I check to see if the window is still running or not?

I'm using this to look at my window:

HWND hWnds = FindWindow(0, WindowName);

 if (hWnds <= 0) {
      gameFound = false;
 } else {
        DWORD pId;
        GetWindowThreadProcessId(hWnds, &pId);
        hProc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pId);

        if (!hProc) {
               std::cout << "Failed.";
        } else {
               std::cout << "Window Found!";

Windows periodically sends out an event that asks if the program is alive, then it waits for it to respond. And if it doesn't respond within a certain amount of time it assumes it has crashed and says "not responding". So what you need to do is handle the window events.

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