您的最佳的信息源和新聞 BIOS, 司機 并且 winvista 在互聯網

景色文章 名列前茅50 景色錄影 景色軟 景色幫助

使用C#發現什麼在過程中為服務跑


注: 原始這個內容從 http://mygreenpaste.blogspot.com. 如果您是讀書它從某一其他站點,請需要時間參觀 我的綠色漿糊,公司. 謝謝。

最近,一單獨去由標記『』張貼的高 一個評論 設置服務過程的優先權通過劇本:

怎麼會I,如果我要,服務是特殊svchost.exe的一部分的發現? 在C#能在做?

謝謝!

我回復了 通過評論,但是你比你在實際blog投稿不太掌握格式化在評論做,因此我計算我這裡會張貼反應。

=================

Tasklist.exe 與/svc氰胍可能告訴您,作為罐頭 處理探險家. 您能也檢查登記確定什麼服務用什麼SVCHOST小組將裝載(參見「查明故障性能問題與自動更新「為更多細節)。

就C#代碼,下列要求在System.Management的參考。 調用節目,通過它過程的過程您是好奇的id,并且它將輸出跑在那個過程中的服務。

使用系統;
使用System.Management;

namespace MyGreenPaste
{
類節目
{
靜止空主要(串[] args)
{
如果(args.GetLength (0) <= 0)
{
Console.WriteLine (「用法: {0} pid ",
System.IO.Path.GetFileName (
System.Diagnostics.Process.GetCurrentProcess ()。
MainModule.FileName));
Console.WriteLine (「pid是過程id」 +的地方
主持至少一項服務的「過程」);
回歸;
}

嘗試
{
ManagementObjectSearcher mos =
新的ManagementObjectSearcher (「根\ \ CIMV2」,
串。格式(「選擇*從Win32_Service」 +
「ProcessId= {0}的地方」, args [0]));
foreach (ManagementObject結果在mos。得到())
{
Console.WriteLine (「{0} -> {1} 「結果[「名字」],
結果[「DisplayName」]);
}
}
抓住(ManagementException mex)
{
Console.WriteLine (「**錯誤詢問的WMI :{0} {1}」,
System.Environment.NewLine, mex。消息);
}
}
}
}
大眾化: 2%


由Â寫「/\/\ Ø|ö±à ² \/Â」 ®©。 讀的更加偉大的飼料在是來源 網站
沒有評論.
讀更多文章 處理探險家 并且 tasklist 并且 WMI 并且 SVCHOST 并且 otherSoftware 并且 c# 并且 過程 并且 服務.

相關文章

No comments

There are still no comments on this article.

Leave your comment...

If you want to leave your comment on this article, simply fill out the next form:




You can use these XHTML tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong> .