监视并重新启动应用程序 [英] Monitor and Restart Application
问题描述
我正在一个需要监视选定程序的应用程序上工作,如果该程序已崩溃或无法正常工作,则需要启动.我从2天开始搜索代码,但能够找到功能示例但找不到代码
功能性就像它在此链接中的工作方式一样http://www.mydigitallife.info/2008/10/10/tips-of-how-to-restart-crashed-applications-automatically-in-windows-pc/
任何人都可以向我提供用于监视和重新启动选定程序的代码吗?
Hi,
I am working on an application where i need to monitor a selected program and if it is crashed or not working i need to start.I am searching for the code from 2 days but I am able to find functionality samples but couldnt find the code
The functioality is just like how it works in this link http://www.mydigitallife.info/2008/10/10/tips-of-how-to-restart-crashed-applications-automatically-in-windows-pc/
Can anyone pls provide me the code for monitoring and restarting a selected program
推荐答案
您必须使用SendMessageTimeout
API函数并发送正在被消息以及超时(从0到15秒,以毫秒为单位).
转到此处了解如何在C#应用程序中使用此功能:
http://www.pinvoke.net/default.aspx/user32.SendMessageTimeout [ ^ ]
You have to use theSendMessageTimeout
API function and send the application being mounitored theWM_NULL
message, along with the timeout (from 0 to 15 seconds, expressed in milliseconds).
Go here to learn how to use this function in a C# application:
http://www.pinvoke.net/default.aspx/user32.SendMessageTimeout[^]
哦,我的天哪,在.net Framework中无法执行此操作,必须调用WIN32 API
这是C#的噩梦,您应该使用DELPHI或VC ++来做到这一点
oh my god ,this things can''t to do in .net Framework,you must call ths WIN32 API
this is a nightmare in C# ,you should use DELPHI OR VC++ to do this
这篇关于监视并重新启动应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!