计算机的cpu能不能直接运行vb,如何用VB读取计算机主板或CPU的机器码?

推荐回答

仅仅几行代码实现取得本机CPU序列号,可以使用此序列号实现程序的注册功能。个人感觉使用CPU序列号注册比使用硬盘序列号更为适合。引用MicrosoftWMIScriptingv1.1Library''添加Command1PrivateSubCommand1_ClickDimcpuSetAsSWbemObjectSetDimcpuAsSWbemObjectSetcpuSet=GetObject"winmgmts:{impersonationLevel=impersonate}".InstancesOf"Win32_Processor"ForEachcpuIncpuSetMsgBox"CPU系列号:"&cpu.ProcessorId取得CPU序列号NextEndSub''---------------------------------------如果没有那个MicrosoftWMIScriptingv1.1Library,你也可以添加工程,添加两个command和一个text,然后代码:PrivateTypeOSVERSIONINFOdwOSVersionInfoSizeAsLongdwMajorVersionAsLongdwMinorVersionAsLongdwBuildNumberAsLongdwPlatformIdAsLongszCSDVersionAsString*128''MaintenancestringforPSSusageEndTypePrivateDeclareFunctionGetVersionExLib"kernel32"Alias"GetVersionExA"lpVersionInformationAsOSVERSIONINFOAsLongPrivateDeclareFunctionGetComputerNameLib"kernel32"Alias"GetComputerNameA"ByVallpBufferAsString,nSizeAsLongAsLongPrivateConstVER_PLATFORM_WIN32_NT=2PrivateConstVER_PLATFORM_WIN32_WINDOWS=1PrivateConstVER_PLATFORM_WIN32s=0PrivateSubCommand1_ClickDimlen5AsLong,aaAsLongDimcmprNameAsStringDimosverAsOSVERSIONINFO''取得ComputerNamecmprName=String255,0len5=256aa=GetComputerNamecmprName,len5cmprName=LeftcmprName,InStr1,cmprName,Chr0-1Computer=cmprName''取得CPU端口号SetCPUs=GetObject"winmgmts:{impersonationLevel=impersonate}!\\"&Computer&"oot\cimv2".ExecQuery"select*fromWin32_Processor"ForEachmycpuInCPUsText1.Text=mycpu.ProcessorIdNextEndSubPrivateSubCommand2_ClickUnloadMeEndSub。

黄登红2019-10-15 11:05:19

卓优商学提示您:回答为网友贡献,仅供参考。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值