要获取系统的这些信息,在不使用wmi服务的情况下进行操作,因为这个服务可能运行不正常,这样就会导致数据无法采集,除了性能计数器之外还可以用什么方式进行数据的采集,kernel32.dll这个类库运行是否基于windows的服务,知道的朋友麻烦指点一下,谢谢。
还有就是性能计数器的计数类型有哪些?
如"Processor", "% Processor Time", "_Total"
"Process", "Working Set", "_Total"

解决方案 »

  1.   


    [StructLayout(LayoutKind.Sequential)]
    public struct SYSTEM_INFO
    {
        internal int dwOemId;
        internal int dwPageSize;
        internal IntPtr lpMinimumApplicationAddress;
        internal IntPtr lpMaximumApplicationAddress;
        internal IntPtr dwActiveProcessorMask;
        internal int dwNumberOfProcessors;
        internal int dwProcessorType;
        internal int dwAllocationGranularity;
        internal short wProcessorLevel;
        internal short wProcessorRevision;
    }[DllImport("kernel32.dll", SetLastError=true)]
    public static extern void GetSystemInfo(ref SYSTEM_INFO lpSystemInfo); 
      

  2.   

    internal 请改成 public,写错了.
      

  3.   

    其他一些信息
    NetworkInterface.GetIsNetworkAvailable();
    DriveInfo.GetDrives();
      

  4.   

    DriveInfo[] drivers = DriveInfo.GetDrives();
    PerformanceCounter cpuCounter;
    PerformanceCounter ramCounter;
    cpuCounter = new PerformanceCounter();
    cpuCounter.CategoryName = "";[DllImport("IpHlpApi.dll")]
    extern static public uint GetIfTable(byte[] pIfTable, ref uint pdwSize, bool bOrder);来获取本机网络信息
    http://www.philosophicalgeek.com/2009/01/03/determine-cpu-usage-of-current-process-c-and-c/
      

  5.   

    [StructLayout(LayoutKind.Sequential)]
    public struct SYSTEM_INFO
    {
        internal int dwOemId;
        internal int dwPageSize;
        internal IntPtr lpMinimumApplicationAddress;
        internal IntPtr lpMaximumApplicationAddress;
        internal IntPtr dwActiveProcessorMask;
        internal int dwNumberOfProcessors;
        internal int dwProcessorType;
        internal int dwAllocationGranularity;
        internal short wProcessorLevel;
        internal short wProcessorRevision;
    }[DllImport("kernel32.dll", SetLastError=true)]
    public static extern void GetSystemInfo(ref SYSTEM_INFO lpSystemInfo); 
      

  6.   

    string   strResult;   ManagementClass   diskClass   =   new   ManagementClass( "Win32_LogicalDisk ");   ManagementObjectCollection   disks;   
    disks   =   diskClass.GetInstances();   
    foreach(   ManagementObject   disk   in   disks)   
    {   
    strResult   =   " ";   strResult   +=   "设备ID: "   +   disk[ "DeviceID "];   strResult   +=   "磁盘名称: "   +   disk[ "Name "];   strResult   +=   "磁盘卷标: "   +   disk[ "VolumeName "];   if(   disk[ "FileSystem "].ToString()   !=   " "   )   
    {   
    strResult   +=   "文件系统: "   +   disk[ "FileSystem "];   strResult   +=   "磁盘描述: "   +   disk[ "Description "];   if(   System.Convert.ToInt64(disk[ "Size "])   >   0   )   
    {   
    strResult   +=   "磁盘大小: "   +   System.Convert.ToInt64(disk[ "Size "].ToString());   
    }   
    strResult   +=   "磁盘类型: "   +   System.Convert.ToInt16(disk[ "DriveType "].ToString());   
    }   
    Response.Write(strResult);   
    }   
      

  7.   


    都可以通过performancecounter来获取
    PerformanceCounter pfc = new PerformanceCounter("Processor", "% Processor Time", "_Total");
            PerformanceCounter networkReceivePerformance = new PerformanceCounter("Network Interface", "Bytes Received/sec", "Realtek PCIe FE Family Controller");
            PerformanceCounter networkSendPerformance = new PerformanceCounter("Network Interface", "Bytes Sent/sec", "Realtek PCIe FE Family Controller");
            PerformanceCounter diskPerformance = new PerformanceCounter("LogicalDisk", "% Free Space", "_Total");
            PerformanceCounter memoryPerformance = new PerformanceCounter("Memory", "Available MBytes");