tmpstr=""
set fso=createObject("scriptingfilesystemObject")
Set dc = fsoDrives
for each d in dc
If disReady Then
tmpstr=tmpstr & "磁盘" & dDriveLetter & ":" & vbcrlf &_
"可用空间:" & (dAvailableSpace/1024/1024/1024) & " GB" & vbcrlf &_
"空余空间:" & (dFreeSpace/1024/1024/1024) & " GB" &vbcrlf &_
"总空间大小:" & (dTotalSize/1024/1024/1024) & " GB" &vbcrlf &_
"文件系统:" & dFileSystem & vbcrlf &_
"驱动器类型:" & dDriveType &vbcrlf &_
"是否就绪:" & dIsReady &vbcrlf &_
"路径:" & dPath &vbcrlf &_
"根目录:" & dRootFolder &vbcrlf &_
"序列号:" & dSerialNumber &vbcrlf &_
"共享名:" & dShareName &vbcrlf &_
"卷名:" & dVolumeName &vbcrlf &vbcrlf
End If
Next
msgbox tmpstr
拜托楼上的,人家要用VB写程序,你居然让用其他的工具,有违题意啊……
想要加载Delphi开发的的DLL,需要问写dll的的人,因为每个人写出来的都不一样,这个是不通用的。
VB不能用于写DLL动态链接库文件,M$没给大家这个功能……
Private CPUCounter As New PerformanceCounter("Processor", "% Processor Time", "_Total")
Dim cpu As Integer = CInt(CPUCounterNextValue)
Private Type CounterInfo
hCounter As Long
strName As String
End Type
Private Declare Function PdhCollectQueryData Lib "PDHDLL" (ByVal QueryHandle As Long) As PDH_STATUS
Private Declare Function PdhVbGetDoubleCounterValue Lib "PDHDLL" (ByVal CounterHandle As Long, ByRef CounterStatus As Long) As Double
Private Declare Function PdhOpenQuery Lib "PDHDLL" (ByVal Reserved As Long, ByVal dwUserData As Long, ByRef hQuery As Long) As PDH_STATUS
Private Declare Function PdhVbAddCounter Lib "PDHDLL" (ByVal QueryHandle As Long, ByVal CounterPath As String, ByRef CounterHandle As Long) As PDH_STATUS
Dim Counters(0 To 99) As CounterInfo
Dim hQuery As Long
Enum PDH_STATUS
PDH_CSTATUS_VALID_DATA = &H0
PDH_CSTATUS_NEW_DATA = &H1
PDH_CSTATUS_NO_MACHINE = &H800007D0
PDH_CSTATUS_NO_INSTANCE = &H800007D1
PDH_MORE_DATA = &H800007D2
PDH_CSTATUS_ITEM_NOT_VALIDATED = &H800007D3
PDH_RETRY = &H800007D4
PDH_NO_DATA = &H800007D5
PDH_CALC_NEGATIVE_DENOMINATOR = &H800007D6
PDH_CALC_NEGATIVE_TIMEBASE = &H800007D7
PDH_CALC_NEGATIVE_VALUE = &H800007D8
PDH_DIALOG_CANCELLED = &H800007D9
PDH_CSTATUS_NO_OBJECT = &HC0000BB8
PDH_CSTATUS_NO_COUNTER = &HC0000BB9
PDH_CSTATUS_INVALID_DATA = &HC0000BBA
PDH_MEMORY_ALLOCATION_FAILURE = &HC0000BBB
PDH_INVALID_HANDLE = &HC0000BBC
PDH_INVALID_ARGUMENT = &HC0000BBD
PDH_FUNCTION_NOT_FOUND = &HC0000BBE
PDH_CSTATUS_NO_COUNTERNAME = &HC0000BBF
PDH_CSTATUS_BAD_COUNTERNAME = &HC0000BC0
PDH_INVALID_BUFFER = &HC0000BC1
PDH_INSUFFICIENT_BUFFER = &HC0000BC2
PDH_CANNOT_CONNECT_MACHINE = &HC0000BC3
PDH_INVALID_PATH = &HC0000BC4
PDH_INVALID_INSTANCE = &HC0000BC5
PDH_INVALID_DATA = &HC0000BC6
PDH_NO_DIALOG_DATA = &HC0000BC7
PDH_CANNOT_READ_NAME_STRINGS = &HC0000BC8
End Enum
Private Sub UpdateValues()
Dim dblCounterValue As Double
Dim pdhStatus As Long
Dim strInfo As String
Dim i As Long
PdhCollectQueryData (hQuery)
dblCounterValue = _
PdhVbGetDoubleCounterValue(Counters(i)hCounter, pdhStatus)
If (pdhStatus = PDH_CSTATUS_VALID_DATA) _
Or (pdhStatus = PDH_CSTATUS_NEW_DATA) Then
MsgBox "CPU使用情况:" & Format$(dblCounterValue, "00") & "%"
End If
End Sub
Private Sub AddCounter(strCounterName As String, hQuery As Long)
Dim pdhStatus As PDH_STATUS
Dim hCounter As Long
pdhStatus = PdhVbAddCounter(hQuery, strCounterName, hCounter)
Counters(currentCounterIdx)hCounter = hCounter
currentCounterIdx = currentCounterIdx + 1
End Sub
Private Sub Form_Load()
Dim pdhStatus As PDH_STATUS
pdhStatus = PdhOpenQuery(0, 1, hQuery)
AddCounter "\Processor(0)\% Processor Time", hQuery
UpdateValues
End Sub
截下来的代码
以上就是关于vb获取硬件信息的代码全部的内容,包括:vb获取硬件信息的代码、vb6怎样获取硬件信息,比如硬盘、CPU、网卡、机器名、vb怎么计算cpu的利用率等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)