阻止Windows进程 [英] block windows process

查看:139
本文介绍了阻止Windows进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 我想在启动时阻止或休眠Windows进程之一.我有此进程的名称,请问C#对我有什么办法执行此工作?

Hi I want to block or sleep one of the windows process at its start time.I have the name of this process,Is any way for me to do this work by C#?

推荐答案

没有真正的方法可以休眠"另一个进程,但是您可以接近.

下面的示例将终止该过程,如果将名称存储在应用程序中的某个位置,则当您希望再次唤醒时可以手动将其重新启动.
There is no real way to ''sleep'' another process, but you can get close.

The following example will kill the process, if you store the name somewhere in your application you could manually restart it when you want it to ''awake'' again.
try
{
    Process proc = Process.GetProcessesByName("explorer");
    proc.Kill();
}
catch (Exception ex)
{
    ex = null;
}



另一种可行的方法是将其优先级降低到空闲,这将使其消耗最少的CPU时间,就像它处于睡眠状态一样,但是从技术上讲它仍然是清醒的.



Another way to go is to just lower it''s priority to Idle, this will make it consume minimal CPU time, just as if it was asleep, but it will still technically be awake.

try
{
    Process proc = Process.GetProcessesByName("explorer");
    proc.PriorityClass = ProcessPriorityClass.Idle;
}
catch (Exception ex)
{
    ex = null;
}



您可以在此处找到有关Process类的更多详细信息:
http://msdn.microsoft.com/zh-CN /library/system.diagnostics.process(v=vs.100).aspx [



You can find more details on the Process class here:
http://msdn.microsoft.com/en-us/library/system.diagnostics.process(v=vs.100).aspx[^]

Hope this helped.


这篇关于阻止Windows进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆