首页 > 编程 > .NET > 正文

通过WMI获得硬盘和CPU的物理序列号(VB.net)

2024-07-10 13:01:15
字体:
来源:转载
供稿:网友

'获得硬盘序列号

dim cmicwmi as new system.management.managementobjectsearcher("select * from win32_diskdrive")



dim uint32 as uint32

for each cmicwmiobj as managementobject in cmicwmi.get

uint32 = cmicwmiobj("signature")

next

textbox1.text = uint32.tostring





'获得cpu序列号

dim wmi as new system.management.managementobjectsearcher("select * from win32_processor")



dim uint32 as string

for each wmiobj as managementobject in wmi.get

uint32 = wmiobj("processorid")

next

textbox1.text = uint32



'获得硬盘总容量

dim wmi as new system.management.managementobjectsearcher("select * from win32_diskdrive")



dim uint64 as uint64

for each wmiobj as managementobject in wmi.get

uint64 = wmiobj("size")

next

textbox1.text = uint64.tostring

首先,引用system.management;然后在代码中imports system.management;

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表