zoukankan      html  css  js  c++  java
  • 判断窗口是否挂起

    // ishung.cpp (Windows 95/98/NT/2000)
    //
    // This example will show you how you can obtain the current status
    // of the application.
    //
    //
    // (c)1999 Ashot Oganesyan K, SmartLine, Inc
    // mailto:ashot@aha.ru, http://www.protect-me.com, http://www.codepile.com

    #include <windows.h>
    #include <stdio.h>


    // User32!IsHungAppWindow (NT specific!)
    //
    // The function retrieves the status (running or not responding) of the
    // specified application
    //
    // BOOL IsHungAppWindow(
    //   HWND hWnd,        // handle to main app's window
    // );
    typedef BOOL (WINAPI *PROCISHUNGAPPWINDOW)(HWND);


    // User32!IsHungThread (95/98 specific!)
    //
    // The function retrieves the status (running or not responding) of the
    // specified thread
    //
    // BOOL IsHungThread(
    //   DWORD dwThreadId, // The identifier of the main app's window thread
    // );
    typedef BOOL (WINAPI *PROCISHUNGTHREAD)(DWORD);


    PROCISHUNGAPPWINDOW   IsHungAppWindow;
    PROCISHUNGTHREAD   IsHungThread;


    void main(int argc, char* argv[])
    {
     if (argc<2)
     {
      printf("Usage:\n\nishung.exe hWnd\n");
      return;
     }

     HWND hWnd;
     sscanf(argv[1],"%lx",&hWnd);

     if (!IsWindow(hWnd))
     {
      printf("Incorrect window handle\n");
      return;
     }

     HMODULE hUser32 = GetModuleHandle("user32");
     if (!hUser32)
      return;

     IsHungAppWindow = (PROCISHUNGAPPWINDOW)
                                             GetProcAddress( hUser32,
                                                             "IsHungAppWindow" );

     IsHungThread = (PROCISHUNGTHREAD) GetProcAddress( hUser32,
                                                              "IsHungThread" );

     if (!IsHungAppWindow && !IsHungThread)
      return;

     OSVERSIONINFO osver;
     osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
     if (!GetVersionEx(&osver))
      return;

     BOOL IsHung;

     if (osver.dwPlatformId&VER_PLATFORM_WIN32_NT)
      IsHung = IsHungAppWindow(hWnd);
     else
      IsHung = IsHungThread(GetWindowThreadProcessId(hWnd,NULL));

     if (IsHung)
      printf("Not Responding\n");
     else
      printf("Running\n");
    }

  • 相关阅读:
    Apache开启Rewrite环境
    php 写入和读取序列化的cookie
    discuzx 制作单页面
    php 操作postgresql
    已安装php动态安装pdo_mysql
    PHP 异步调用 后台调用 持续执行 断开连接/浏览器
    ssh配置文件详解
    gdb 调试中No symbol in current context 故障定位
    Linking fails : relocation truncated to fit: R_X86_程序占用内存大于2GB所导致的问题
    谨慎使用单精度/双精度数值类型
  • 原文地址:https://www.cnblogs.com/MaxWoods/p/332120.html
Copyright © 2011-2022 走看看