如何用VB程序取得CPU序列号?

jsjkhanwei 2003-03-31 09:44:31
我想用VB程序从机内取得CPU序列号,请知道的朋友解释一下好吗?
...全文
204 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
weill 2003-04-26
  • 打赏
  • 举报
回复
注意,以上代码只是给了你一个得到CPU序列号的函数,在win2K,赛扬III1.7G下测试通过。
weill 2003-04-26
  • 打赏
  • 举报
回复
将以下代码放在一个模块中,然后在任何窗口可用 AA = CPUInof_ME() 的方法调用,注意,其中AA应为String类型。


'得到CPU序列号。********函数引用方法:AA = CPUInof_ME() (其中AA应为String类型)********
Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Const VER_PLATFORM_WIN32_NT = 2
Private Const VER_PLATFORM_WIN32_WINDOWS = 1
Private Const VER_PLATFORM_WIN32s = 0
Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128 ' Maintenance string for PSS usage
End Type

Public Function CPUInfo_ME() As String
Dim len5 As Long, aa As Long
Dim cmprName As String
Dim osver As OSVERSIONINFO
'取得Computer Name
cmprName = String(255, 0)
len5 = 256
aa = GetComputerName(cmprName, len5)
cmprName = Left(cmprName, InStr(1, cmprName, Chr(0)) - 1)
Computer = cmprName '取得CPU端口号
Set CPUs = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & Computer & "\root\cimv2").ExecQuery("select * from Win32_Processor")
For Each mycpu In CPUs
CPUInfo_ME = mycpu.ProcessorId
Next
End Function

1,217

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧