vb.net 获得CPU位数的代码?
答案:3 悬赏:30
解决时间 2021-02-26 23:29
- 提问者网友:夜微涼
- 2021-02-26 03:19
vb.net 获得CPU位数的代码?
最佳答案
- 二级知识专家网友:温柔刺客
- 2021-02-26 04:28
Dim Getip As New System.Management.ManagementObjectSearcher("SELECt * FROM Win32_Processor")
For Each GIP As System.Management.ManagementObject In GETIP.Get
If GIP("AddressWidth").ToString <> "" Then
MsgBox(GIP("AddressWidth").ToString)
End If
Next
For Each GIP As System.Management.ManagementObject In GETIP.Get
If GIP("AddressWidth").ToString <> "" Then
MsgBox(GIP("AddressWidth").ToString)
End If
Next
全部回答
- 1楼网友:不傲怎称霸
- 2021-02-26 05:42
'
'!!!重要:首先要添加“引用”一个dll,选择“system management”;
'
imports microsoft.visualbasic
imports system
imports system.collections.generic
imports system.componentmodel
imports system.data
imports system.drawing
imports system.text
imports system.windows.forms
imports system.management
imports system.io
namespace windowsapplication1
partial public class form1
inherits form
public sub new()
initializecomponent()
end sub
private sub button1_click(byval sender as object, byval e as eventargs)
'获取cpu编号
dim [myclass] as new managementclass("win32_processor")
dim mycollection as managementobjectcollection = [myclass].getinstances()
dim myinfo as string = "当前系统cpu编号是:"
dim mycpuid as string = ""
for each myobject as managementobject in mycollection
mycpuid = myobject.properties("processorid").value.tostring()
exit for
next myobject
myinfo &= mycpuid
messagebox.show(myinfo, "信息提示", messageboxbuttons.ok, messageboxicon.information)
end sub
private sub button2_click(byval sender as object, byval e as eventargs)
'获取计算机cpu的当前电压
dim myinfo as string = "计算机cpu的当前电压是:"
dim mysearcher as new managementobjectsearcher("select * from win32_processor")
for each myobject as managementobject in mysearcher.get()
try
myinfo &= controlchars.lf & string.format("currentvoltage : " & myobject("currentvoltage").tostring())
myinfo &= controlchars.lf & "========================================================="
catch
end try
next myobject
messagebox.show(myinfo, "信息提示", messageboxbuttons.ok, messageboxicon.information)
end sub
private sub button3_click(byval sender as object, byval e as eventargs)
'获取计算机cpu的外部频率
dim myinfo as string = "计算机cpu的外部频率是:"
dim mysearcher as new managementobjectsearcher("select * from win32_processor")
for each myobject as managementobject in mysearcher.get()
try
myinfo &= controlchars.lf & string.format("extclock : " & myobject("extclock").tostring())
myinfo &= controlchars.lf & "========================================================="
catch
end try
next myobject
messagebox.show(myinfo, "信息提示", messageboxbuttons.ok, messageboxicon.information)
end sub
private sub button4_click(byval sender as object, byval e as eventargs)
'获取计算机cpu的二级缓存
dim myinfo as string = "计算机cpu的二级缓存尺寸是:"
dim mysearcher as new managementobjectsearcher("select * from win32_processor")
for each myobject as managementobject in mysearcher.get()
myinfo &= controlchars.lf & string.format("l2cachesize: " & myobject("l2cachesize").tostring())
myinfo &= controlchars.lf & "========================================================="
next myobject
messagebox.show(myinfo, "信息提示", messageboxbuttons.ok, messageboxicon.information)
end sub
private sub button5_click(byval sender as object, byval e as eventargs)
'获取计算机cpu的制造商名称
dim myinfo as string = "计算机cpu的制造商名称是:"
dim mysearcher as new managementobjectsearcher("select * from win32_processor")
for each myobject as managementobject in mysearcher.get()
myinfo &= controlchars.lf & string.format("manufacturer : " & myobject("manufacturer").tostring())
myinfo &= controlchars.lf & "========================================================="
next myobject
messagebox.show(myinfo, "信息提示", messageboxbuttons.ok, messageboxicon.information)
end sub
private sub button6_click(byval sender as object, byval e as eventargs)
'获取计算机cpu的产品名称
dim myinfo as string = "计算机cpu的产品名称是:"
dim mysearcher as new managementobjectsearcher("select * from win32_processor")
for each myobject as managementobject in mysearcher.get()
myinfo &= controlchars.lf & string.format("name : " & myobject("name").tostring())
myinfo &= controlchars.lf & "========================================================="
next myobject
messagebox.show(myinfo, "信息提示", messageboxbuttons.ok, messageboxicon.information)
end sub
private sub button7_click(byval sender as object, byval e as eventargs)
'获取计算机cpu的版本信息
dim myinfo as string = "计算机cpu的版本信息如下:"
dim mysearcher as new managementobjectsearcher("select * from win32_processor")
for each myobject as managementobject in mysearcher.get()
myinfo &= controlchars.lf & string.format("version: " & myobject("version").tostring())
myinfo &= controlchars.lf & "========================================================="
next myobject
messagebox.show(myinfo, "信息提示", messageboxbuttons.ok, messageboxicon.information)
end sub
private sub button8_click(byval sender as object, byval e as eventargs)
'获取计算机cpu的当前使用百分比 注意要把sqlserver或者其他耗cpu的软件开着否则看不到效果就一直为0
dim myinfo as string = "计算机cpu的当前使用百分比是:"
dim mysearcher as new managementobjectsearcher("select * from win32_processor")
for each myobject as managementobject in mysearcher.get()
myinfo &= controlchars.lf & string.format("loadpercentage : " & myobject("loadpercentage").tostring())
myinfo &= controlchars.lf & "========================================================="
next myobject
messagebox.show(myinfo, "信息提示", messageboxbuttons.ok, messageboxicon.information)
end sub
private sub button9_click(byval sender as object, byval e as eventargs)
'获取计算机cpu的最大时钟频率
dim myinfo as string = "计算机cpu的最大时钟频率是:"
dim mysearcher as new managementobjectsearcher("select * from win32_processor")
for each myobject as managementobject in mysearcher.get()
myinfo &= controlchars.lf & string.format("maxclockspeed : " & myobject("maxclockspeed").tostring())
myinfo &= controlchars.lf & "========================================================="
next myobject
messagebox.show(myinfo, "信息提示", messageboxbuttons.ok, messageboxicon.information)
end sub
private sub button10_click(byval sender as object, byval e as eventargs)
'获取计算机cpu的当前时钟频率
dim myinfo as string = "计算机cpu的当前时钟频率是:"
dim mysearcher as new managementobjectsearcher("select * from win32_processor")
for each myobject as managementobject in mysearcher.get()
myinfo &= controlchars.lf & string.format("currentclockspeed : " & myobject("currentclockspeed").tostring())
myinfo &= controlchars.lf & "========================================================="
next myobject
messagebox.show(myinfo, "信息提示", messageboxbuttons.ok, messageboxicon.information)
end sub
private sub button11_click(byval sender as object, byval e as eventargs)
'获取计算机的cpu地址宽度
dim myinfo as string = "当前计算机的cpu地址宽度是:"
dim mysearcher as new managementobjectsearcher("select * from win32_processor")
for each myobject as managementobject in mysearcher.get()
myinfo &= controlchars.lf & string.format("addresswidth: " & myobject("addresswidth").tostring())
myinfo &= controlchars.lf & "========================================================="
next myobject
messagebox.show(myinfo, "信息提示", messageboxbuttons.ok, messageboxicon.information)
end sub
private sub button14_click(byval sender as object, byval e as eventargs)
'获取计算机的cpu数据宽度
dim myinfo as string = "当前计算机的cpu数据宽度是:"
dim mysearcher as new managementobjectsearcher("select * from win32_processor")
for each myobject as managementobject in mysearcher.get()
myinfo &= controlchars.lf & string.format("datawidth : " & myobject("datawidth").tostring())
myinfo &= controlchars.lf & "========================================================="
next myobject
messagebox.show(myinfo, "信息提示", messageboxbuttons.ok, messageboxicon.information)
end sub
end class
- 2楼网友:末路丶一枝花
- 2021-02-26 05:07
Dim cpuSet
Dim cpu
Set cpuSet = GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf("Win32_Processor")
For Each cpu In cpuSet
a = (cpu.ProcessorId)
Next
a变量就保存着cpu码
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯
• 手机登qq时,显示手机磁盘不足,清理后重新登 |
• 刺客的套装怎么选啊? |