<p> PerformanceCounter PTCounter = new PerformanceCounter("Process",<br> "% Processor Time",<br> "AliIM");<br> logfile("% Processor Time:" + PTCounter.NextValue().ToString());<br> //内存<br> PerformanceCounter WSCounter = new PerformanceCounter("Process",<br> "Working Set",<br> "AliIM");<br> logfile("Working Set:" + ((double)WSCounter.NextValue() / 1024).ToString());</p>
<p> //内存最高值<br> PerformanceCounter MemeryCounter = new PerformanceCounter("Process",<br> "Working Set Peak",<br> "AliIM");<br> logfile("Working Set Peak:" + ((double)MemeryCounter.NextValue() / 1024).ToString());</p>
<p><br> //虚拟内存<br> PerformanceCounter PBCounter = new PerformanceCounter("Process",<br> "Private Bytes",<br> "AliIM");<br> logfile("Private Bytes:" + ((double)PBCounter.NextValue() / 1024).ToString());</p>
<p> //句柄数<br> PerformanceCounter HCCounter = new PerformanceCounter("Process",<br> "Handle Count",<br> "AliIM");<br> logfile("Handle Count:" + HCCounter.NextValue() .ToString());</p>
<p> //线程数Thread Count<br> PerformanceCounter TCCounter = new PerformanceCounter("Process",<br> "Thread Count",<br> "AliIM");<br> logfile("Thread Count:" + TCCounter.NextValue() .ToString());</p>
<p></p>
<p>//补充得到GDI OBJECTS</p>
<p> Process process;<br> process = System.Diagnostics.Process.GetProcessesByName("AliIM")[0];<br><br> logfile("GDI Objects Count:" + GetGuiResources(process.Handle, 0));</p>
<p></p>
<p> [DllImport("User32")]</p>
<p> extern public static int GetGuiResources(IntPtr hProcess, int uiFlags);</p>
<p></p>
<p></p>
<p></p>
<p></p>
<p> //内存最高值<br> PerformanceCounter MemeryCounter = new PerformanceCounter("Process",<br> "Working Set Peak",<br> "AliIM");<br> logfile("Working Set Peak:" + ((double)MemeryCounter.NextValue() / 1024).ToString());</p>
<p><br> //虚拟内存<br> PerformanceCounter PBCounter = new PerformanceCounter("Process",<br> "Private Bytes",<br> "AliIM");<br> logfile("Private Bytes:" + ((double)PBCounter.NextValue() / 1024).ToString());</p>
<p> //句柄数<br> PerformanceCounter HCCounter = new PerformanceCounter("Process",<br> "Handle Count",<br> "AliIM");<br> logfile("Handle Count:" + HCCounter.NextValue() .ToString());</p>
<p> //线程数Thread Count<br> PerformanceCounter TCCounter = new PerformanceCounter("Process",<br> "Thread Count",<br> "AliIM");<br> logfile("Thread Count:" + TCCounter.NextValue() .ToString());</p>
<p></p>
<p>//补充得到GDI OBJECTS</p>
<p> Process process;<br> process = System.Diagnostics.Process.GetProcessesByName("AliIM")[0];<br><br> logfile("GDI Objects Count:" + GetGuiResources(process.Handle, 0));</p>
<p></p>
<p> [DllImport("User32")]</p>
<p> extern public static int GetGuiResources(IntPtr hProcess, int uiFlags);</p>
<p></p>
<p></p>
<p></p>
<p></p>