VB如何读取主板号或CPU号?

heartdied 2002-04-29 04:26:14
VB如何读取主板号或CPU号?
有人说可以通过GetSystemInfo来读取系统信息,可里面的参数怎么写呀!
...全文
255 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
y1g1y1 2002-08-11
  • 打赏
  • 举报
回复
http://www.csdn.net/Expert/TopicView1.asp?id=928731
xxfly 2002-06-07
  • 打赏
  • 举报
回复
这里有一个关于磁盘序列号文章,不知是否有用

磁盘序列号在每次软盘或硬盘格式化后都重新生成,并且不回重复。许多程序员用此加密。其实也可以修改该函数,可以得到磁盘卷标和文件系统类型信息。

声明:
Private Declare Function GetVolumeInformation Lib "kernel32.dll" Alias _
  "GetVolumeInformationA" (ByVal lpRootPathName As String, ByVal _
  lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Integer, _
  lpVolumeSerialNumber As Long, lpMaximumComponentLength As Long, _
  lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As String, _
  ByVal nFileSystemNameSize As Long) As Long

代码:

Function GetSerialNumber(sRoot As String) As Long
  Dim lSerialNum As Long
  Dim R As Long
  Dim strLabel As String, strType As String
  strLabel = String$(255, Chr$(0))
  '磁盘卷标
  strType = String$(255, Chr$(0))
  '文件系统类型 一般为 FAT
  R = GetVolumeInformation(sRoot, strLabel, Len(strLabel), _
    lSerialNum, 0, 0, strType, Len(strType))
  GetSerialNumber = lSerialNum
  '在 strLabel 中为 磁盘卷标
  '在 strType 中为 文件系统类型
End Function

用法:

当驱动器不存在时,函数返回 0。如果是个非根目录,也将返回 0:

lSerial = GetSerialNumber("c:\")
subbee 2002-06-07
  • 打赏
  • 举报
回复
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
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 = 0Dim 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
msgbox mycpu.ProcessorId
Next

xinxiu 2002-04-29
  • 打赏
  • 举报
回复
那你也给我发送一个这样的例子吧
hoqido@371.net
zenghrong 2002-04-29
  • 打赏
  • 举报
回复
GetCPUDescriptionString(Verbose:=CBool(chkVerbose.Value))
tony_jian 2002-04-29
  • 打赏
  • 举报
回复
我有例子tony_jian@163.net

7,785

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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