如何用excel vba读取CPU或硬盘的机器码?
2013-03-31
展开全部
Sub Auto_Open()
On Error Resume Next
Set fs = CreateObject("Scripting.FileSystemObject")
StrDrive = "B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z"
StrDriveArray = Split(StrDrive, ",")
For StartPos = 1 To UBound(StrDriveArray)
Set d = fs.GetDrive(fs.GetDriveName(fs.GetAbsolutePathName(StrDriveArray(StartPos) & ":\\")))
If d.DriveType = 1 Then
s = d.SerialNumber
Exit For
End If
Next
If s <> "" Then
Range("Sheet1!d8") = s
Else
Range("Sheet1!d8") = "系统未检测到U盘!"
End If
Set d = Nothing
Set fs = Nothing
Call QueryOther
End Sub
On Error Resume Next
Set fs = CreateObject("Scripting.FileSystemObject")
StrDrive = "B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z"
StrDriveArray = Split(StrDrive, ",")
For StartPos = 1 To UBound(StrDriveArray)
Set d = fs.GetDrive(fs.GetDriveName(fs.GetAbsolutePathName(StrDriveArray(StartPos) & ":\\")))
If d.DriveType = 1 Then
s = d.SerialNumber
Exit For
End If
Next
If s <> "" Then
Range("Sheet1!d8") = s
Else
Range("Sheet1!d8") = "系统未检测到U盘!"
End If
Set d = Nothing
Set fs = Nothing
Call QueryOther
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询