本文整理汇总了C#中ProcessHandle.IsCritical方法的典型用法代码示例。如果您正苦于以下问题:C# ProcessHandle.IsCritical方法的具体用法?C# ProcessHandle.IsCritical怎么用?C# ProcessHandle.IsCritical使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProcessHandle
的用法示例。
在下文中一共展示了ProcessHandle.IsCritical方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Prompt
private static bool Prompt(IWin32Window window, int[] pids, string[] names,
string action, string content, bool promptOnlyIfDangerous)
{
if (!Settings.Instance.WarnDangerous)
return true;
string name = "the selected process(es)";
if (pids.Length == 1)
name = names[0];
else
name = "the selected processes";
bool dangerous = false;
foreach (int pid in pids)
{
if (PhUtils.IsDangerousPid(pid))
{
dangerous = true;
break;
}
}
bool critical = false;
foreach (int pid in pids)
{
try
{
using (var phandle = new ProcessHandle(pid, ProcessAccess.QueryInformation))
{
if (phandle.IsCritical())
{
critical = true;
break;
}
}
}
catch
{ }
}
if (promptOnlyIfDangerous && !dangerous && !critical)
return true;
DialogResult result = DialogResult.No;
if (OSVersion.HasTaskDialogs)
{
TaskDialog td = new TaskDialog();
td.WindowTitle = "Process Hacker";
td.MainInstruction = "Do you want to " + action + " " + name + "?";
td.Content = content;
if (critical)
{
td.MainIcon = TaskDialogIcon.Warning;
td.Content = "You are about to " + action + " one or more CRITICAL processes. " +
"Windows is designed to break (crash) when one of these processes is terminated. " +
"Are you sure you want to continue?";
}
else if (dangerous)
{
td.MainIcon = TaskDialogIcon.Warning;
td.Content = "You are about to " + action + " one or more system processes. " +
"Doing so will cause system instability. Are you sure you want to continue?";
}
if (pids.Length > 1)
{
td.ExpandFooterArea = true;
td.ExpandedInformation = "Processes:\r\n";
for (int i = 0; i < pids.Length; i++)
{
bool dangerousPid, criticalPid;
dangerousPid = PhUtils.IsDangerousPid(pids[i]);
try
{
using (var phandle = new ProcessHandle(pids[i], ProcessAccess.QueryInformation))
criticalPid = phandle.IsCritical();
}
catch
{
criticalPid = false;
}
td.ExpandedInformation += names[i] + " (PID " + pids[i].ToString() + ")" +
(dangerousPid ? " (system process) " : "") +
(criticalPid ? " (CRITICAL) " : "") +
"\r\n";
}
td.ExpandedInformation = td.ExpandedInformation.Trim();
}
//.........这里部分代码省略.........