Beispiel #1
0
        private SystemModel GetChassisAndTag(SystemModel systemModel)
        {
            ManagementObjectSearcher searcher =
                new ManagementObjectSearcher("root\\CIMV2",
                                             "SELECT * FROM Win32_SystemEnclosure");

            foreach (ManagementObject queryObj in searcher.Get())
            {
                if (queryObj["ChassisTypes"] == null)
                {
                    systemModel.EnclosureType = "Unknown";
                }
                else
                {
                    UInt16[] arrChassisTypes = (UInt16[])(queryObj["ChassisTypes"]);
                    foreach (UInt16 arrValue in arrChassisTypes)
                    {
                        systemModel.EnclosureType = ChassisInfo.GetChassisDetails(arrValue).Trim();
                        break;
                    }
                }
                systemModel.AssetTag = Convert.ToString(queryObj["SMBIOSAssetTag"]).Trim();
            }
            return(systemModel);
        }
Beispiel #2
0
        public SystemModel GetSystemModelDetails()
        {
            SystemModel systemModel           = new SystemModel();
            ManagementObjectSearcher searcher =
                new ManagementObjectSearcher("root\\CIMV2",
                                             "SELECT * FROM Win32_ComputerSystemProduct");

            foreach (ManagementObject queryObj in searcher.Get())
            {
                systemModel.SerialNumber = Convert.ToString(queryObj["IdentifyingNumber"]).Trim();
                systemModel.Manufacturer = Convert.ToString(queryObj["Vendor"]).Trim();
                systemModel.Model        = Convert.ToString(queryObj["Name"]).Trim();
                systemModel.Version      = Convert.ToString(queryObj["Version"]).Trim();
            }
            GetChassisAndTag(systemModel);
            return(systemModel);
        }