回复 6楼 风吹过b
谢谢斑竹的回复。我现在弄出点门道了。是通过两个按钮实现的。按下第一个按钮,抓取CPU成功。按下第二个按钮,写文件成功。但是还有问题。下面是代码:
Private Sub Command1_Click()
MsgBox GetCpu
End Sub
Public Function GetCpu() As String
On Error Resume Next
Dim TmpCode$
Dim ObjWMIService As Object, objItem As Object, colItems As Object
Set ObjWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colItems = ObjWMIService.ExecQuery("Select * from Win32_Processor", , 48)
For Each objItem In colItems
TmpCode = TmpCode & " " & objItem.ProcessorId
Next
GetCpu = Trim(TmpCode)
End Function
Private Sub Command2_Click()
Open "F:\aa.dat" For Output As #1
Write #1, GetCpu
Close #1
End Sub
问题是:1.按下第一个按钮后,抓到CPU的序列号的时候,电脑会“嘟”一身,并且会弹出一个方块,把抓到序列号显示出来了。怎样去掉“嘟”声?怎样不弹出这个方块呢?还望斑竹伸出援手啊!