java中的移位運算符心得總結。本站提示廣大學習愛好者:(java中的移位運算符心得總結)文章只能為提供參考,不一定能成為您想要的結果。以下是java中的移位運算符心得總結正文
ChassisTypes 屬性可以告知您,您應用的是筆記本電腦、台式盤算機照樣其他類型的盤算機。哦,輸出。以下劇本可讓您曉得您應用的是哪一種類型的盤算機:
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colChassis = objWMIService.ExecQuery _
("Select * from Win32_SystemEnclosure")
For Each objChassis in colChassis
For Each strChassisType in objChassis.ChassisTypes
Wscript.Echo strChassisType
Next
Next
好吧,以上劇本只是在必定水平上讓您曉得您應用的是哪一種類型的盤算機。現實上,ChassisType 屬性前往的是一個數字,這就是說當我們在眼前的盤算機上運轉這個劇本時,我們將獲得 10。那末,甚麼是 10 呢?依據WMI SDK,它指的是筆記本盤算機。猜一猜會產生甚麼呢?沒錯!
但您其實不必每次檢討盤算機類型時都參考 SDK。以下經由擴大的劇本應用一個 Select Case 語句,它可將這些整數轉換為更成心義的內容:
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colChassis = objWMIService.ExecQuery _
("Select * from Win32_SystemEnclosure")
For Each objChassis in colChassis
For Each strChassisType in objChassis.ChassisTypes
Select Case strChassisType
Case 1
Wscript.Echo "Other"
Case 2
Wscript.Echo "Unknown"
Case 3
Wscript.Echo "Desktop"
Case 4
Wscript.Echo "Low Profile Desktop"
Case 5
Wscript.Echo "Pizza Box"
Case 6
Wscript.Echo "Mini Tower"
Case 7
Wscript.Echo "Tower"
Case 8
Wscript.Echo "Portable"
Case 9
Wscript.Echo "Laptop"
Case 10
Wscript.Echo "Notebook"
Case 11
Wscript.Echo "Handheld"
Case 12
Wscript.Echo "Docking Station"
Case 13
Wscript.Echo "All-in-One"
Case 14
Wscript.Echo "Sub-Notebook"
Case 15
Wscript.Echo "Space Saving"
Case 16
Wscript.Echo "Lunch Box"
Case 17
Wscript.Echo "Main System Chassis"
Case 18
Wscript.Echo "Expansion Chassis"
Case 19
Wscript.Echo "Sub-Chassis"
Case 20
Wscript.Echo "Bus Expansion Chassis"
Case 21
Wscript.Echo "Peripheral Chassis"
Case 22
Wscript.Echo "Storage Chassis"
Case 23
Wscript.Echo "Rack Mount Chassis"
Case 24
Wscript.Echo "Sealed-Case PC"
Case Else
Wscript.Echo "Unknown"
End Select
Next
Next
在您發問之前,不,我們其實不曉得這些年夜多半盤算機類型是甚麼,也不曉得便攜式盤算機、膝上型盤算機和筆記本盤算機之間有甚麼差別。我們也不曉得 ChassisTypes 屬性為何存儲為數組。那能否意味著一台盤算機可以有多種盤算機類型?不要問我們,我們也不曉得。讓我們喘口吻吧:究竟我們只是 Microsoft Scripting Guy,可不是 Microsoft Hardware Guy