|
說明 之前是透過GetSystemInfo去取得,所能得知的部分有限,透過Windows的WMI Script我們可以得到更多更進一步的資料,如Processor ID,2階快取大小等等 程式 '先由VB選單中的 Private CpuPath() As String Private oSWbemObjectSet As SWbemObjectSet Private oSWbemServices As SWbemServices Private Sub Form_Load() Dim oCpu As SWbemObject 'WMI Object Dim nCpu As Long, sPath As String Set oSWbemServices = GetObject("winmgmts:") '取得CPU set Set oSWbemObjectSet = oSWbemServices.InstancesOf("Win32_Processor") List1.Clear '列出所有的CPU For Each oCpu In oSWbemObjectSet With oCpu sPath = .Path_ & vbNullString If sPath <> vbNullString Then List1.AddItem .Name '儲存CPU Path ReDim Preserve CpuPath(nCpu) As String CpuPath(nCpu) = sPath nCpu = nCpu + 1 End If End With Next If List1.ListCount Then List1.ListIndex = 0 End Sub Private Sub Form_Unload(Cancel As Integer) Set oSWbemObjectSet = Nothing Set oSWbemServices = Nothing End Sub Private Sub List1_Click() Dim oCpu As SWbemObject Dim sInfoString As String On Error Resume Next Set oCpu = oSWbemObjectSet(CpuPath(List1.ListIndex)) List2.Clear With oCpu List2.AddItem "Processor ID: " & .ProcessorID & vbCrLf List2.AddItem "Description: " & .Description & vbCrLf List2.AddItem "Status: " & .Status & vbCrLf List2.AddItem "Manufacturer: " & .Manufacturer & vbCrLf List2.AddItem "Availability: " & sAvailability(.Availability) & vbCrLf List2.AddItem "Load Percentage: " & .LoadPercentage & vbCrLf List2.AddItem "Current Clock Speed: " & .CurrentClockSpeed & " MHz" & vbCrLf List2.AddItem "Maximum Clock Speed: " & .MaxClockSpeed & vbCrLf List2.AddItem "Level 2 Cache Size: " & .L2CacheSize & vbCrLf List2.AddItem "Level 2 Cache Speed: " & .L2CacheSpeed & vbCrLf List2.AddItem "Power Management Supported: " & .PowerManagementSupported End With End Sub Private Function sAvailability(Code As Integer) As String Select Case Code Case 3 sAvailability = "Running/Full Power" Case 4 sAvailability = "Warning" Case 5 sAvailability = "In Test" Case 6 sAvailability = "Not Applicable" Case 7 sAvailability = "Power Off" Case 8 sAvailability = "Off Line" Case 9 sAvailability = "Off Duty" Case 10 sAvailability = "Degraded" Case 11 sAvailability = "Not Installed" Case 12 sAvailability = "Install Error" Case 13 sAvailability = "Power Save - Unknown" Case 14 sAvailability = "Power Save - Low Power Mode" Case 15 sAvailability = "Power Save - Standby" Case 16 sAvailability = "Power Cycle" Case 17 sAvailability = "Power Save - Warning" Case Else sAvailability = "Unknown" End Select End Function 程式下載
文件出處 Honey 整理時間 2003,1,29. |
|
|
|
如果對本站有任何建議,歡迎來信給Honey,我們會盡快給您答覆 |