我在哪里可以获得有关笔记本型号名称的信息?

时间:2013-05-12 13:59:09

标签: c# wmi sysinfo

我试图从笔记本电脑获取有关硬件的信息。我通过WMI这样做,但并不总是包含有关笔记本型号的信息。这取决于制造商,SONY从不在WMI中包含硬件信息。

            FileStream fs = new FileStream(@"C:\log.txt", FileMode.OpenOrCreate);
        StreamWriter sw = new StreamWriter(fs);
        string[] Names = { "Win32_Fan", "Win32_HeatPipe", "Win32_Refrigeration", "Win32_TemperatureProbe", "Win32_Keyboard", "Win32_PointingDevice",
                             "Win32_AutochkSetting", "Win32_CDROMDrive" , "Win32_DiskDrive" ,"Win32_FloppyDrive", "Win32_PhysicalMedia","Win32_TapeDrive" ,
                         "Win32_1394Controller","Win32_1394ControllerDevice", "Win32_AllocatedResource", "Win32_AssociatedProcessorMemory","Win32_BaseBoard",
                         "Win32_BIOS", "Win32_Bus","Win32_CacheMemory","Win32_ControllerHasHub","Win32_DeviceBus","Win32_DeviceMemoryAddress", "Win32_DeviceSettings",
                         "Win32_DMAChannel","Win32_FloppyController","Win32_IDEController","Win32_IDEControllerDevice","Win32_InfraredDevice","Win32_IRQResource","Win32_MemoryArray",
                         "Win32_MemoryArrayLocation","Win32_MemoryDevice","Win32_MemoryDeviceArray","Win32_MemoryDeviceLocation","Win32_MotherboardDevice","Win32_OnBoardDevice",
                         "Win32_ParallelPort","Win32_PCMCIAController","Win32_PhysicalMemory","Win32_PhysicalMemoryArray","Win32_PhysicalMemoryLocation","Win32_PNPAllocatedResource",
                         "Win32_PNPDevice","Win32_PNPEntity","Win32_PortConnector","Win32_PortResource","Win32_Processor","Win32_SCSIController", "Win32_SCSIControllerDevice","Win32_SerialPort",
                         "Win32_SerialPortConfiguration","Win32_SerialPortSetting","Win32_SMBIOSMemory","Win32_SoundDevice","Win32_SystemBIOS","Win32_SystemDriverPNPEntity","Win32_SystemEnclosure",
                         "Win32_SystemMemoryResource","Win32_SystemSlot","Win32_USBController","Win32_USBControllerDevice","Win32_USBHub","Win32_NetworkAdapter",
                         "Win32_NetworkAdapterConfiguration","Win32_NetworkAdapterSetting","Win32_Battery","Win32_CurrentProbe","Win32_PortableBattery",
                         "Win32_PowerManagementEvent","Win32_VoltageProbe","Win32_DriverForDevice","Win32_Printer","Win32_PrinterConfiguration","Win32_PrinterController",
                         "Win32_PrinterDriver","Win32_PrinterDriverDll","Win32_PrinterSetting","Win32_PrintJob","Win32_TCPIPPrinterPort","Win32_POTSModem","Win32_POTSModemToSerialPort",
                         "Win32_DesktopMonitor","Win32_DisplayConfiguration","Win32_DisplayControllerConfiguration","Win32_VideoConfiguration","Win32_VideoController","Win32_VideoSettings"};

        foreach (string name in Names)
        {
            sw.WriteLine("                                                                           ");
            sw.WriteLine("<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
            sw.WriteLine(name);
            sw.WriteLine("<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");

            ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM " + name);
            ManagementObjectCollection information = searcher.Get();

            foreach (ManagementObject obj in information)
            {

                foreach (PropertyData data in obj.Properties)
                {

                    sw.WriteLine("{0} = {1}", data.Name, data.Value);
                }
            }

        }
        sw.Close();

我在哪里可以获得此信息? 谢谢!

2 个答案:

答案 0 :(得分:1)

您可以尝试从BIOS信息中获取此信息,该信息存储在HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\BIOS下的注册表中。它应该在SystemProductNameSystemVersion值。

答案 1 :(得分:0)

模型和序列号包含在“Win32_ComputerSystemProduct”中。