本文整理汇总了C#中ServiceProvider.RunOnce方法的典型用法代码示例。如果您正苦于以下问题:C# ServiceProvider.RunOnce方法的具体用法?C# ServiceProvider.RunOnce怎么用?C# ServiceProvider.RunOnce使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ServiceProvider
的用法示例。
在下文中一共展示了ServiceProvider.RunOnce方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessCommandLine
private static bool ProcessCommandLine(Dictionary<string, string> pArgs)
{
if (pArgs.ContainsKey("-e"))
{
try
{
ExtendedCmd.Run(pArgs);
}
catch (Exception ex)
{
PhUtils.ShowException("Unable to complete the operation", ex);
}
return true;
}
if (pArgs.ContainsKey("-installkph"))
{
try
{
using (var scm = new ServiceManagerHandle(ScManagerAccess.CreateService))
{
using (var shandle = scm.CreateService(
"KProcessHacker",
"KProcessHacker",
ServiceType.KernelDriver,
ServiceStartType.SystemStart,
ServiceErrorControl.Ignore,
Application.StartupPath + "\\kprocesshacker.sys",
null,
null,
null
))
{
shandle.Start();
}
}
}
catch (WindowsException ex)
{
Environment.Exit((int)ex.ErrorCode);
}
return true;
}
if (pArgs.ContainsKey("-uninstallkph"))
{
try
{
using (var shandle = new ServiceHandle("KProcessHacker", ServiceAccess.Stop | (ServiceAccess)StandardRights.Delete))
{
try { shandle.Control(ServiceControl.Stop); }
catch { }
shandle.Delete();
}
}
catch (WindowsException ex)
{
Environment.Exit((int)ex.ErrorCode);
}
return true;
}
if (pArgs.ContainsKey("-ip"))
InspectPid = int.Parse(pArgs["-ip"]);
if (pArgs.ContainsKey("-pw"))
{
int pid = int.Parse(pArgs["-pw"]);
SharedThreadProvider = new SharedThreadProvider(Properties.Settings.Default.RefreshInterval);
SecondarySharedThreadProvider = new SharedThreadProvider(Properties.Settings.Default.RefreshInterval);
ProcessProvider = new ProcessSystemProvider();
ServiceProvider = new ServiceProvider();
SharedThreadProvider.Add(ProcessProvider);
SharedThreadProvider.Add(ServiceProvider);
ProcessProvider.RunOnce();
ServiceProvider.RunOnce();
ProcessProvider.Enabled = true;
ServiceProvider.Enabled = true;
Win32.LoadLibrary(Properties.Settings.Default.DbgHelpPath);
if (!ProcessProvider.Dictionary.ContainsKey(pid))
{
PhUtils.ShowError("The process (PID " + pid.ToString() + ") does not exist.");
Environment.Exit(0);
return true;
}
ProcessWindow pw = new ProcessWindow(ProcessProvider.Dictionary[pid]);
Application.Run(pw);
//.........这里部分代码省略.........