示例#1
0
        /// <summary>
        /// Метод, возвращающий объект класса SystemOperationInfo, в котором содержится информация об операционной системе ПК
        /// </summary>
        /// <returns>Объект класса OperatingSystemInfo</returns>
        public static OperatingSystemInfo SystemInfo()
        {
            OperatingSystemInfo systemInfo = null;

            ManagementObjectSearcher searcher =
                new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_OperatingSystem");

            foreach (ManagementObject queryObj in searcher.Get())
            {
                int    buildNumber = int.Parse(queryObj["BuildNumber"].ToString());
                string caption     = queryObj["Caption"].ToString();
                uint   phys_memory = uint.Parse(queryObj["FreePhysicalMemory"].ToString());
                uint   virt_memory = uint.Parse(queryObj["FreeVirtualMemory"].ToString());
                string name        = queryObj["Name"].ToString();
                int    os          = int.Parse(queryObj["OSType"].ToString());
                string user        = queryObj["RegisteredUser"].ToString();
                string serial      = queryObj["SerialNumber"].ToString();
                int    major_ver   = int.Parse(queryObj["ServicePackMajorVersion"].ToString());
                int    minor_ver   = int.Parse(queryObj["ServicePackMinorVersion"].ToString());
                string status      = queryObj["Status"].ToString();
                string sys_device  = queryObj["SystemDevice"].ToString();
                string sys_dir     = queryObj["SystemDirectory"].ToString();
                string sys_drive   = queryObj["SystemDrive"].ToString();
                string version     = queryObj["Version"].ToString();
                string win_dir     = queryObj["WindowsDirectory"].ToString();

                systemInfo = new OperatingSystemInfo(buildNumber, caption, phys_memory,
                                                     virt_memory, name, os, user, serial,
                                                     major_ver, minor_ver, status, sys_device,
                                                     sys_dir, sys_drive, version, win_dir);
            }

            return(systemInfo);
        }
示例#2
0
 public CollectedInfo(List <string> processes, OperatingSystemInfo sys_info, List <DiskInfo> disks_info,
                      List <VideoControllerInfo> vid_info,
                      double av_phys_mem, double av_virt_mem, string cpu, bool alert)
 {
     this.processes   = processes;
     this.sys_info    = sys_info;
     this.disks_info  = disks_info;
     this.vid_info    = vid_info;
     this.av_phys_mem = av_phys_mem;
     this.av_virt_mem = av_virt_mem;
     this.cpu         = "CPU";
     ip         = Dns.GetHostByName(Dns.GetHostName()).AddressList[0].ToString();
     need_alert = alert;
 }