中易网

vb.net 获得CPU位数的代码?

答案:3  悬赏:30  
解决时间 2021-02-26 23:29
vb.net 获得CPU位数的代码?
最佳答案
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
全部回答
' '!!!重要:首先要添加“引用”一个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
Dim cpuSet Dim cpu Set cpuSet = GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf("Win32_Processor") For Each cpu In cpuSet a = (cpu.ProcessorId) Next a变量就保存着cpu码
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
怎么算一个圆的面积,周长
求倩女幽魂公会YY的频道设计,多形式的娱乐公
女生身高165能考服装表演哪些大学
ds18b20的读取值乘以0.0625后为啥要乘10??
6、5的内径购买翡翠手镯需要多大的尺寸
显卡上集成的声卡怎么禁掉
新买的ipad2,求真伪,型号:mc982zp/a,序列
检验科与手术室能否在同一层楼
程锦广告(解放中路36号-12)地址好找么,我有
急!办商业网站收入和费用
新速腾1.4T 怎样能开到百公里加速9
荷花代表什么
这个是什么字体?急急急!!!
提问!关於日剧假面骑士电王KIVA
(123乘12乘6)除(12乘3乘123)的简便算法
推荐资讯
佳梦苑宾馆地址在哪,我要去那里办事
对比仲裁和诉讼的特点并作出利弊分析 财管
暴雨天路面积水深闯红灯罚吗
有一道题:计算(2x^3-3x^2y-2xy^2)-(x^3-2
王者荣耀铭文到底有没有用
我在工厂上班工伤工厂他什么保险都没有买怎么
大学读出来真的一点用都没有,为什么老人都是
请问驯龙高手还有哪些番外?????
黄圣依的男人是谁啊?韩雪的背景是什么?
mfc中无法打开包包括文件“iostream.h”
华人快递转运是在海关处就转发ems吗,我收到
郑州哪里找得到贴地砖的工人
手机登qq时,显示手机磁盘不足,清理后重新登
刺客的套装怎么选啊?