用vb获取计算机信息
1.IP、MAC、计算机名、当前用户名2.所有磁盘空间、内存空间3.获取当前时间、日期4.电脑各项配置注意是vb6.0,而不是vb.net...
1.IP、MAC、计算机名、当前用户名
2.所有磁盘空间、内存空间
3.获取当前时间、日期
4.电脑各项配置
注意是vb6.0,而不是vb.net 展开
2.所有磁盘空间、内存空间
3.获取当前时间、日期
4.电脑各项配置
注意是vb6.0,而不是vb.net 展开
1个回答
展开全部
模块
Public Function CheckComm()
On Error Resume Next
Set wshshell = CreateObject("wscript.shell")
wshshell.run ("%comspec% /c net start winmgmt"), 0
'用一个文本来记录硬件信息
'Set WshNetwork = CreateObject("WScript.Network")
'ComputerName = WshNetwork.ComputerName
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
'主板
Set board = objWMIService.ExecQuery("select * from win32_baseboard")
For Each item In board
board2 = "主板:" & item.Product
Next
'CPU
Set cpu = objWMIService.ExecQuery("select * from win32_processor")
For Each item In cpu
cpu2 = "cpu:" & item.Name
Next
'内存
Set colItems = objWMIService.ExecQuery("Select * from Win32_PhysicalMemory", , 48)
Dim memory1
For Each objItem In colItems
a = objItem.capacity / 1048576
temp = temp + Val(objItem.capacity)
If InStr(memory1, "1条" & a & "M") <> 0 Then
memory1 = Replace(memory1, "1条" & a & "M", "2条" & a & "M")
ElseIf InStr(memory1, "2条" & a & "M") <> 0 Then
memory1 = Replace(memory1, "2条" & a & "M", "3条" & a & "M")
ElseIf InStr(memory1, "3条" & a & "M") <> 0 Then
memory1 = Replace(memory1, "3条" & a & "M", "4条" & a & "M")
Else
memory1 = memory1 & "1条" & a & "M"
End If
n = n + 1
Next
memory = temp / 1048576
If n = 1 Then
memory2 = "内存条:" & memory1
Else
memory2 = "内存条:" & memory1 & " 总计" & memory & "M"
End If
'硬盘
Set disk = objWMIService.ExecQuery("select * from win32_diskdrive")
For Each item In disk
disk2 = "硬盘:" & item.Model
Next
'显卡
Set video = objWMIService.ExecQuery("select * from win32_videocontroller", , 48)
For Each item In video
video2 = "显卡:" & item.Description
Next
'网卡
Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkAdapter", , 48)
For Each objItem In colItems
If (Left(objItem.NetConnectionID, 4) = "本地连接") Then
lanname = "网卡:" & objItem.Name
End If
Next
lan2 = lanname
Dim thecomputer(6)
thecomputer(0) = board2
thecomputer(1) = cpu2
thecomputer(2) = memory2
thecomputer(3) = disk2
thecomputer(4) = video2
thecomputer(5) = lan2
CheckComm = thecomputer
End Function
代码
Private Sub Form_Load()
List4.Clear
List4.AddItem "Computer Info" ' & vbCrLf
List4.AddItem "***********************" ' & vbCrLf
Dim I As Integer, c
c = CheckComm
For I = 0 To 5
List4.AddItem c(I)
Next
Dim s, System, item, d() As String
Set System = GetObject("winmgmts:").InstancesOf("Win32_ComputerSystem")
For Each item In System 'List1.AddItem item.cputype
's = "Computer Info" & vbCrLf
's = s & "***********************" & vbCrLf
s = s & "计算机名称: " & item.Name & vbCrLf
s = s & "状态: " & item.Status & vbCrLf
s = s & "类型: " & item.SystemType & vbCrLf
s = s & "生产厂家: " & item.Manufacturer & vbCrLf
s = s & "型号: " & item.Model & vbCrLf
s = s & "内存: ~" & item.totalPhysicalMemory \ 1024000 & "mb" & vbCrLf
s = s & "域: " & item.domain & vbCrLf
's = s & "工作组" & item.Workgroup & vbCrLf '获得工作组和域的选项不能同时用
s = s & "当前用户: " & item.UserName & vbCrLf
s = s & "启动状态" & item.BootupState & vbCrLf
s = s & "该计算机属于" & item.PrimaryOwnerName & vbCrLf
s = s & "系统类型" & item.CreationClassName & vbCrLf
s = s & "计算机类类型" & item.Description & vbCrLf
On Error GoTo 1
For I = 0 To 1 '这里假设安装了两个系统
s = s & Chr(5) & "启动选项" & I & " :" & item.SystemStartupOptions(I) _
& vbCrLf
Next I
1:
Next
d = Split(s, vbCrLf)
For I = 0 To UBound(d)
List4.AddItem d(I)
Next
End Sub
要求一个list4
Public Function CheckComm()
On Error Resume Next
Set wshshell = CreateObject("wscript.shell")
wshshell.run ("%comspec% /c net start winmgmt"), 0
'用一个文本来记录硬件信息
'Set WshNetwork = CreateObject("WScript.Network")
'ComputerName = WshNetwork.ComputerName
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
'主板
Set board = objWMIService.ExecQuery("select * from win32_baseboard")
For Each item In board
board2 = "主板:" & item.Product
Next
'CPU
Set cpu = objWMIService.ExecQuery("select * from win32_processor")
For Each item In cpu
cpu2 = "cpu:" & item.Name
Next
'内存
Set colItems = objWMIService.ExecQuery("Select * from Win32_PhysicalMemory", , 48)
Dim memory1
For Each objItem In colItems
a = objItem.capacity / 1048576
temp = temp + Val(objItem.capacity)
If InStr(memory1, "1条" & a & "M") <> 0 Then
memory1 = Replace(memory1, "1条" & a & "M", "2条" & a & "M")
ElseIf InStr(memory1, "2条" & a & "M") <> 0 Then
memory1 = Replace(memory1, "2条" & a & "M", "3条" & a & "M")
ElseIf InStr(memory1, "3条" & a & "M") <> 0 Then
memory1 = Replace(memory1, "3条" & a & "M", "4条" & a & "M")
Else
memory1 = memory1 & "1条" & a & "M"
End If
n = n + 1
Next
memory = temp / 1048576
If n = 1 Then
memory2 = "内存条:" & memory1
Else
memory2 = "内存条:" & memory1 & " 总计" & memory & "M"
End If
'硬盘
Set disk = objWMIService.ExecQuery("select * from win32_diskdrive")
For Each item In disk
disk2 = "硬盘:" & item.Model
Next
'显卡
Set video = objWMIService.ExecQuery("select * from win32_videocontroller", , 48)
For Each item In video
video2 = "显卡:" & item.Description
Next
'网卡
Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkAdapter", , 48)
For Each objItem In colItems
If (Left(objItem.NetConnectionID, 4) = "本地连接") Then
lanname = "网卡:" & objItem.Name
End If
Next
lan2 = lanname
Dim thecomputer(6)
thecomputer(0) = board2
thecomputer(1) = cpu2
thecomputer(2) = memory2
thecomputer(3) = disk2
thecomputer(4) = video2
thecomputer(5) = lan2
CheckComm = thecomputer
End Function
代码
Private Sub Form_Load()
List4.Clear
List4.AddItem "Computer Info" ' & vbCrLf
List4.AddItem "***********************" ' & vbCrLf
Dim I As Integer, c
c = CheckComm
For I = 0 To 5
List4.AddItem c(I)
Next
Dim s, System, item, d() As String
Set System = GetObject("winmgmts:").InstancesOf("Win32_ComputerSystem")
For Each item In System 'List1.AddItem item.cputype
's = "Computer Info" & vbCrLf
's = s & "***********************" & vbCrLf
s = s & "计算机名称: " & item.Name & vbCrLf
s = s & "状态: " & item.Status & vbCrLf
s = s & "类型: " & item.SystemType & vbCrLf
s = s & "生产厂家: " & item.Manufacturer & vbCrLf
s = s & "型号: " & item.Model & vbCrLf
s = s & "内存: ~" & item.totalPhysicalMemory \ 1024000 & "mb" & vbCrLf
s = s & "域: " & item.domain & vbCrLf
's = s & "工作组" & item.Workgroup & vbCrLf '获得工作组和域的选项不能同时用
s = s & "当前用户: " & item.UserName & vbCrLf
s = s & "启动状态" & item.BootupState & vbCrLf
s = s & "该计算机属于" & item.PrimaryOwnerName & vbCrLf
s = s & "系统类型" & item.CreationClassName & vbCrLf
s = s & "计算机类类型" & item.Description & vbCrLf
On Error GoTo 1
For I = 0 To 1 '这里假设安装了两个系统
s = s & Chr(5) & "启动选项" & I & " :" & item.SystemStartupOptions(I) _
& vbCrLf
Next I
1:
Next
d = Split(s, vbCrLf)
For I = 0 To UBound(d)
List4.AddItem d(I)
Next
End Sub
要求一个list4
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询