真心请教大牛,急急急!!!

kllll1119 2013-11-27 10:15:56
请问,C++如何判断一个进程或一个程序处于未响应状态或崩溃状态呢?
...全文
195 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
baichi4141 2013-11-27
  • 打赏
  • 举报
回复
所谓的未响应,就是你理它它不理你,只要一个程序不理睬外部跟它的联系,就是未响应。 至于崩溃,那就看程序本身的特点了。例如一个执行超复杂运算的程序,如果机器配置很低,那么可能要运算很久,这期间操作系统肯定报这程序未响应,你能说这程序崩溃了吗?
ztenv 版主 2013-11-27
  • 打赏
  • 举报
回复
引用 楼主 kllll1119 的回复:
请问,C++如何判断一个进程或一个程序处于未响应状态或崩溃状态呢?
1、不同的平台有不同的实现 2、可以监测线程的状态、数量;可以写一个狗与其保持心跳,没有心跳了即认为死了 等等多种方法
www_adintr_com 2013-11-27
  • 打赏
  • 举报
回复
程序不响应就是程序不处理用户或系统发送的消息了,只要向他发一个消息看能不能达到处理后的效果就知道了。
sleeplacker 2013-11-27
  • 打赏
  • 举报
回复
编译器做不到,只能在写代码的时候尽量避免这些情况的发生
赵4老师 2013-11-27
  • 打赏
  • 举报
回复
IsHungAppWindow Function -------------------------------------------------------------------------------- You call the IsHungAppWindow function to determine if Microsoft Windows considers that a specified application is not responding. An application is considered to be not responding if it is not waiting for input, is not in startup processing, and has not called PeekMessage within the internal timeout period of 5 seconds. Syntax BOOL IsHungAppWindow( HWND hWnd ); Parameters hWnd [in] Handle to the window. Return Value Returns TRUE if the window stops responding, otherwise returns FALSE. Ghost windows always return TRUE. Remarks The Windows timeout criteria of 5 seconds is subject to change. Although you can access this function by using LoadLibrary and GetProcAddress combined in Windows versions prior to Windows XP, the function is not accessible using the standard Include file and library linkage. The header files included in Windows XP Service Pack 1 (SP1) and Windows Server 2003 document this function and make it accessible using the appropriate Include file and library linkage. However, this function is not intended for general use. It is recommended that you do not use it in new programs because it might be altered or unavailable in subsequent versions of Windows. Function Information Minimum DLL Version user32.dll Header Declared in Winuser.h, include Windows.h Import library User32.lib Minimum operating systems Windows 2000 See Also Windows Overview, IsWindow --------------------------------------------------------------------------------

64,282

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧