程序代码: | [ 复制代码到剪贴板 ] |
Imports System.Management
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'获取操作系统序列号
MsgBox(GetSerialNumber())
End Sub
' 获取操作系统序列号
Public Function GetSerialNumber() As String
Dim Result As String = ""
Dim mClass As ManagementClass = New ManagementClass("Win32_OperatingSystem")
Dim moCollection As ManagementObjectCollection = mClass.GetInstances()
For Each mObject As ManagementObject In moCollection
Result = mObject("SerialNumber").ToString
Next
Return Result
End Function
End Class
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'获取操作系统序列号
MsgBox(GetSerialNumber())
End Sub
' 获取操作系统序列号
Public Function GetSerialNumber() As String
Dim Result As String = ""
Dim mClass As ManagementClass = New ManagementClass("Win32_OperatingSystem")
Dim moCollection As ManagementObjectCollection = mClass.GetInstances()
For Each mObject As ManagementObject In moCollection
Result = mObject("SerialNumber").ToString
Next
Return Result
End Function
End Class
不仅可以获得操作系统序列号还可以:
BootDevice
BuildNumber
BuildType
Caption
CodeSet
CountryCode
CreationClassName
CSCreationClassName
CSDVersion
CSName
CurrentTimeZone
DataExecutionPrevention_32BitApplications
DataExecutionPrevention_Available
DataExecutionPrevention_Drivers
DataExecutionPrevention_SupportPolicy
Debug
Description
Distributed
EncryptionLevel
ForegroundApplicationBoost
FreePhysicalMemory
FreeSpaceInPagingFiles
FreeVirtualMemory
InstallDate
LargeSystemCache
LastBootUpTime
LocalDateTime
Locale
Manufacturer
MaxNumberOfProcesses
MaxProcessMemorySize
Name
NumberOfLicensedUsers
NumberOfProcesses
NumberOfUsers
Organization
OSLanguage
OSProductSuite
OSType
OtherTypeDescription
PlusProductID
PlusVersionNumber
Primary
ProductType
QuantumLength
QuantumType
RegisteredUser
SerialNumber
ServicePackMajorVersion
ServicePackMinorVersion
SizeStoredInPagingFiles
Status
SuiteMask
SystemDevice
SystemDirectory
SystemDrive
TotalSwapSpaceSize
TotalVirtualMemorySize
TotalVisibleMemorySize
Version
WindowsDirectory
BuildNumber
BuildType
Caption
CodeSet
CountryCode
CreationClassName
CSCreationClassName
CSDVersion
CSName
CurrentTimeZone
DataExecutionPrevention_32BitApplications
DataExecutionPrevention_Available
DataExecutionPrevention_Drivers
DataExecutionPrevention_SupportPolicy
Debug
Description
Distributed
EncryptionLevel
ForegroundApplicationBoost
FreePhysicalMemory
FreeSpaceInPagingFiles
FreeVirtualMemory
InstallDate
LargeSystemCache
LastBootUpTime
LocalDateTime
Locale
Manufacturer
MaxNumberOfProcesses
MaxProcessMemorySize
Name
NumberOfLicensedUsers
NumberOfProcesses
NumberOfUsers
Organization
OSLanguage
OSProductSuite
OSType
OtherTypeDescription
PlusProductID
PlusVersionNumber
Primary
ProductType
QuantumLength
QuantumType
RegisteredUser
SerialNumber
ServicePackMajorVersion
ServicePackMinorVersion
SizeStoredInPagingFiles
Status
SuiteMask
SystemDevice
SystemDirectory
SystemDrive
TotalSwapSpaceSize
TotalVirtualMemorySize
TotalVisibleMemorySize
Version
WindowsDirectory
以上各属性,不一定都能用上面的代码获得,可能要修改代码。
[本日志由 tiancao1001 于 2013-01-17 08:35 PM 编辑]
|
暂时没有评论
发表评论 - 不要忘了输入验证码哦! |