PerformanceCounter PTCounter = new PerformanceCounter("Process",
                                        "% Processor Time",
                                         "AliIM");
            logfile("% Processor Time:" + PTCounter.NextValue().ToString());
            //内存
            PerformanceCounter WSCounter = new PerformanceCounter("Process",
                                                                    "Working Set",
                                                                     "AliIM");
            logfile("Working Set:" + ((double)WSCounter.NextValue() / 1024).ToString());
            //内存最高值
            PerformanceCounter MemeryCounter = new PerformanceCounter("Process",
                                                                    "Working Set Peak",
                                                                     "AliIM");
            logfile("Working Set Peak:" + ((double)MemeryCounter.NextValue() / 1024).ToString());

            //虚拟内存
            PerformanceCounter PBCounter = new PerformanceCounter("Process",
                                                              "Private Bytes",
                                                               "AliIM");
            logfile("Private Bytes:" + ((double)PBCounter.NextValue() / 1024).ToString());
            //句柄数
            PerformanceCounter HCCounter = new PerformanceCounter("Process",
                                                  "Handle Count",
                                                   "AliIM");
            logfile("Handle Count:" + HCCounter.NextValue() .ToString());
            //线程数Thread Count
            PerformanceCounter TCCounter = new PerformanceCounter("Process",
                                      "Thread Count",
                                       "AliIM");
            logfile("Thread Count:" + TCCounter.NextValue() .ToString());
//补充得到GDI OBJECTS
            Process process;
            process = System.Diagnostics.Process.GetProcessesByName("AliIM")[0];
           
            logfile("GDI Objects Count:" + GetGuiResources(process.Handle, 0));
        [DllImport("User32")]
        extern public static int GetGuiResources(IntPtr hProcess, int uiFlags);