程序代码: | [ 复制代码到剪贴板 ] |
Imports System.Management
Public Class Form1
'获取CPU名称
Public Function GetCPUName() As String
Dim Result As String = ""
Dim mClass As ManagementClass = New ManagementClass("Win32_Processor")
Dim moCollection As ManagementObjectCollection = mClass.GetInstances()
For Each mObject As ManagementObject In moCollection
Result = mObject("Name").ToString
Next
Return Result
End Function
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'获取CPU名称
MsgBox(GetCPUName)
End Sub
End Class
Public Class Form1
'获取CPU名称
Public Function GetCPUName() As String
Dim Result As String = ""
Dim mClass As ManagementClass = New ManagementClass("Win32_Processor")
Dim moCollection As ManagementObjectCollection = mClass.GetInstances()
For Each mObject As ManagementObject In moCollection
Result = mObject("Name").ToString
Next
Return Result
End Function
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'获取CPU名称
MsgBox(GetCPUName)
End Sub
End Class
不仅可以获得CPU名称还可以:
AddressWidth
Architecture
Availability
Caption
ConfigManagerErrorCode
ConfigManagerUserConfig
CpuStatus
CreationClassName
CurrentClockSpeed
CurrentVoltage
DataWidth
Description
DeviceID
ErrorCleared
ErrorDescription
ExtClock
Family
InstallDate
L2CacheSize
L2CacheSpeed
LastErrorCode
Level
LoadPercentage
Manufacturer
MaxClockSpeed
Name
NumberOfCores
NumberOfLogicalProcessors
OtherFamilyDescription
PNPDeviceID
NAME="PowerManagementCapabilities
PowerManagementSupported
ProcessorId
ProcessorType
Revision
ole
Status
StatusInfo
Stepping
SystemCreationClassName
SystemName
UniqueId
UpgradeMethod
Version
VoltageCaps
Architecture
Availability
Caption
ConfigManagerErrorCode
ConfigManagerUserConfig
CpuStatus
CreationClassName
CurrentClockSpeed
CurrentVoltage
DataWidth
Description
DeviceID
ErrorCleared
ErrorDescription
ExtClock
Family
InstallDate
L2CacheSize
L2CacheSpeed
LastErrorCode
Level
LoadPercentage
Manufacturer
MaxClockSpeed
Name
NumberOfCores
NumberOfLogicalProcessors
OtherFamilyDescription
PNPDeviceID
NAME="PowerManagementCapabilities
PowerManagementSupported
ProcessorId
ProcessorType
Revision
ole
Status
StatusInfo
Stepping
SystemCreationClassName
SystemName
UniqueId
UpgradeMethod
Version
VoltageCaps
以上各属性,不一定都能用上面的代码获得,可能要修改代码。
[本日志由 tiancao1001 于 2013-01-17 08:35 PM 编辑]
|
暂时没有评论
发表评论 - 不要忘了输入验证码哦! |