''' <summary>
''' 枚举WMI
''' </summary>
Public Enum HardwareEnum
' 硬件
Win32_Processor
' CPU 处理器
Win32_PhysicalMemory
' 物理内存条
Win32_Keyboard
' 键盘
Win32_PointingDevice
' 点输入设备,包括鼠标。
Win32_FloppyDrive
' 软盘驱动器
Win32_DiskDrive
' 硬盘驱动器
Win32_CDROMDrive
' 光盘驱动器
Win32_BaseBoard
' 主板
Win32_BIOS
' BIOS 芯片
Win32_ParallelPort
' 并口
Win32_SerialPort
' 串口
Win32_SerialPortConfiguration
' 串口配置
Win32_SoundDevice
' 多媒体设置,一般指声卡。
Win32_SystemSlot
' 主板插槽 (ISA & PCI & AGP)
Win32_USBController
' USB 控制器
Win32_NetworkAdapter
' 网络适配器
Win32_NetworkAdapterConfiguration
' 网络适配器设置
Win32_Printer
' 打印机
Win32_PrinterConfiguration
' 打印机设置
Win32_PrintJob
' 打印机任务
Win32_TCPIPPrinterPort
' 打印机端口
Win32_POTSModem
' MODEM
Win32_POTSModemToSerialPort
' MODEM 端口
Win32_DesktopMonitor
' 显示器
Win32_DisplayConfiguration
' 显卡
Win32_DisplayControllerConfiguration
' 显卡设置
Win32_VideoController
' 显卡细节。
Win32_VideoSettings
' 显卡支持的显示模式。
' 操作系统
Win32_TimeZone
' 时区
Win32_SystemDriver
' 驱动程序
Win32_DiskPartition
' 磁盘分区
Win32_LogicalDisk
' 逻辑磁盘
Win32_LogicalDiskToPartition
' 逻辑磁盘所在分区及始末位置。
Win32_LogicalMemoryConfiguration
' 逻辑内存配置
Win32_PageFile
' 系统页文件信息
Win32_PageFileSetting
' 页文件设置
Win32_BootConfiguration
' 系统启动配置
Win32_ComputerSystem
' 计算机信息简要
Win32_OperatingSystem
' 操作系统信息
Win32_StartupCommand
' 系统自动启动程序
Win32_Service
' 系统安装的服务
Win32_Group
' 系统管理组
Win32_GroupUser
' 系统组帐号
Win32_UserAccount
' 用户帐号
Win32_Process
' 系统进程
Win32_Thread
' 系统线程
Win32_Share
' 共享
Win32_NetworkClient
' 已安装的网络客户端
Win32_NetworkProtocol
' 已安装的网络协议
Win32_PnPEntity
'all device
End Enum
''' <summary>
''' WMI取硬件信息
''' </summary>
''' <param name="hardType"></param>
''' <param name="propKey"></param>
''' <returns></returns>
Public Shared Function MulGetHardwareInfo(hardType As HardwareEnum, propKey As String) As String()
Dim strs As New List(Of String)()
Try
Using searcher As New ManagementObjectSearcher("select * from " + hardType)
Dim hardInfos As Object = searcher.[Get]()
For Each hardInfo As Object In hardInfos
If hardInfo.Properties(propKey).Value.ToString().Contains("COM") Then
strs.Add(hardInfo.Properties(propKey).Value.ToString())
End If
Next
searcher.Dispose()
End Using
Return strs.ToArray()
Catch
Return Nothing
Finally
strs = Nothing
End Try
End Function
'通过WMI获取COM端口
Dim ss As String() = MulGetHardwareInfo(HardwareEnum.Win32_PnPEntity, "Name")
Win32_OperatingSystem class
2018/05/31
24 分钟阅读时长
The Win32_OperatingSystem WMI class represents a Windows-based operating system installed on a computer.
The following syntax is simplified from Managed Object Format (MOF) code and includes all of the inherited properties. Properties and methods are in alphabetic order, not MOF order.
Syntax
syntax
复制
[Singleton, Dynamic, Provider("CIMWin32"), SupportsUpdate, UUID("{8502C4DE-5FBB-11D2-AAC1-006008C78BC7}"), AMENDMENT]
class Win32_OperatingSystem : CIM_OperatingSystem
{
string BootDevice;
string BuildNumber;
string BuildType;
string Caption;
string CodeSet;
string CountryCode;
string CreationClassName;
string CSCreationClassName;
string CSDVersion;
string CSName;
sint16 CurrentTimeZone;
boolean DataExecutionPrevention_Available;
boolean DataExecutionPrevention_32BitApplications;
boolean DataExecutionPrevention_Drivers;
uint8 DataExecutionPrevention_SupportPolicy;
boolean Debug;
string Description;
boolean Distributed;
uint32 EncryptionLevel;
uint8 ForegroundApplicationBoost = 2;
uint64 FreePhysicalMemory;
uint64 FreeSpaceInPagingFiles;
uint64 FreeVirtualMemory;
datetime InstallDate;
uint32 LargeSystemCache;
datetime LastBootUpTime;
datetime LocalDateTime;
string Locale;
string Manufacturer;
uint32 MaxNumberOfProcesses;
uint64 MaxProcessMemorySize;
string MUILanguages[];
string Name;
uint32 NumberOfLicensedUsers;
uint32 NumberOfProcesses;
uint32 NumberOfUsers;
uint32 OperatingSystemSKU;
string Organization;
string OSArchitecture;
uint32 OSLanguage;
uint32 OSProductSuite;
uint16 OSType;
string OtherTypeDescription;
Boolean PAEEnabled;
string PlusProductID;
string PlusVersionNumber;
boolean PortableOperatingSystem;
boolean Primary;
uint32 ProductType;
string RegisteredUser;
string SerialNumber;
uint16 ServicePackMajorVersion;
uint16 ServicePackMinorVersion;
uint64 SizeStoredInPagingFiles;
string Status;
uint32 SuiteMask;
string SystemDevice;
string SystemDirectory;
string SystemDrive;
uint64 TotalSwapSpaceSize;
uint64 TotalVirtualMemorySize;
uint64 TotalVisibleMemorySize;
string Version;
string WindowsDirectory;
uint8 QuantumLength;
uint8 QuantumType;