How to detect if an application has stopped responing

xiaoxiao2021-03-06  40

Introduction: This article describes how to use C , VB, Windows API, and .NET class libraries to determine if a process stops responding. There is no definition of a clear "stop response", such as a multi-top window application such as Internet Explorer or Word 2000, there may be some case where the top window is lost, and it is difficult to define whether the application stops responding. But in general, many applications have only one iconic window (or called the main window). If the main window does not respond to user operation over a period of time, the application is stopped responded (for example, when Internet Explorer waits for the remote FTP server). Although this often belongs to other applications, it should be properly considered, but if your application relies on such a program without source code level control, it should provide a chance to allow users to interrupt waiting or simply termination of external applications. application. A API ISHUNGAPPWINDOW is available in Windows2000 and Windows XP, but Microsoft declares that this function may delete this function in subsequent Windows versions. No need to regret, there is a special message WM_NULL in Windows 32, which indicates that it can determine if a window stops responding with SendMessageTimeout. In general, we need to get the symbolic window of the process (or the main window) to perform this judgment. July 2002 MSDN Magazine Q & A Column Article Get The Main Window, Get EXE NAME illustrates how to do this. Unfortunately, the HOW DETECT IF An Application Has Stopped Responding by accessing the browser object bypass this process by accessing the browser object, perhaps because of the cumbers of ENUMWindow in the VB; see the Enumerating Windows Using API in the appendix (Vb). In addition, a RESPONDING attribute is provided in the .NET Framework, which can be used to detect if the process stops responding. The two .NET-based articles in the appendix are to check this property. It seems that it seems to be solved by checking if the window indicated by the mainwindowhandle indicated by the process. The disadvantage of judging this method is that the time waiting for timeout is not set.

转载请注明原文地址:https://www.9cbs.com/read-74578.html

New Post(0)