VB.NET實(shí)例教程之查詢系統(tǒng)啟動(dòng)信息案例剖析
在網(wǎng)上看到大家對VB.Net調(diào)用WMI實(shí)現(xiàn)系統(tǒng)管理都很感興趣,在此呢VB實(shí)例教程來教你VB.NET如何調(diào)用WMI來實(shí)現(xiàn)系統(tǒng)管理和系統(tǒng)信息查詢等問題的解決! 趕快看看吧!
VB.Net調(diào)用WMI可以實(shí)現(xiàn)系統(tǒng)管理和系統(tǒng)信息查詢等。WMI全稱為Windows Management Instrumentation,利用WMI我們可以實(shí)現(xiàn)很多系統(tǒng)管理的功能,msdn在.Net Framework類庫中對此描述比較簡單(因?yàn)樵缙赪MI相關(guān)專題有所較詳盡描述,故類庫中未再詳細(xì)解說與演示)。
開發(fā)環(huán)境: VB2005 Windows2003
本實(shí)例需要在菜單欄中的“項(xiàng)目”-“ 添加引用” -“ System.Management”并在實(shí)例代碼中導(dǎo)入引用的項(xiàng)目和程序集中定義的命名空間或編程元素 即: Imports System.Management
VB.NET實(shí)例教程之VB.NET查詢系統(tǒng)啟動(dòng)信息的實(shí)例
代碼如下:
- Private Sub Lobdotcn()
- Dim Lob_Searcher As New ManagementObjectSearcher("root\CIMV2", "SELECT * FROM Win32_BootConfiguration")
- For Each Obj_Query As ManagementObject In Lob_Searcher.Get()
- ListBox1.Items.Add("樂博網(wǎng)LOB.Cn VB.Net愛好者的組織")
- ListBox1.Items.Add("BootDirectory: " & Obj_Query("BootDirectory"))
- ListBox1.Items.Add("Caption: " & Obj_Query("Caption"))
- ListBox1.Items.Add("ConfigurationPath: " & Obj_Query("ConfigurationPath"))
- ListBox1.Items.Add("Description: " & Obj_Query("Description"))
- ListBox1.Items.Add("LastDrive: " & Obj_Query("LastDrive"))
- ListBox1.Items.Add("Name: " & Obj_Query("Name"))
- ListBox1.Items.Add("ScratchDirectory: " & Obj_Query("ScratchDirectory"))
- ListBox1.Items.Add("SettingID: " & Obj_Query("SettingID"))
- ListBox1.Items.Add("TempDirectory: " & Obj_Query("TempDirectory"))
- Next
- End Sub
相關(guān)屬性說明:
- BootDirectory
- Data type: string
- Access type: Read-only
- Path to the system files required for booting the system.
- Example: "C:\Windows"
- Caption
- Data type: string
- Access type: Read-only
- Qualifiers: MaxLen(64)
- Short description (one-line string) of the CIM_Setting object. This property is inherited from CIM_Setting.
- ConfigurationPath
- Data type: string
- Access type: Read-only
- Path to the configuration files. This value may be similar to the value in the BootDirectory property.
- Description
- Data type: string
- Access type: Read-only
- Description of the CIM_Setting object. This property is inherited from CIM_Setting.
- LastDrive
- Data type: string
- Access type: Read-only
- Last drive letter to which a physical drive is assigned.
- Example: "E:"
- Name
- Data type: string
- Access type: Read-only
- Qualifiers: Key, MaxLen(256)
- Name of the boot configuration. It is an identifier for the boot configuration.
- ScratchDirectory
- Data type: string
- Access type: Read-only
- Directory where temporary files can reside during boot time.
- SettingID
- Data type: string
- Access type: Read-only
- Qualifiers: MaxLen(256)
- Identifier by which the CIM_Setting object is known. This property is inherited from CIM_Setting.
- TempDirectory
- Data type: string
- Access type: Read-only
- Directory where temporary files are stored.
- Example: "C:\TEMP"
以上就是VB.NET實(shí)例教程中VB.NET查詢系統(tǒng)啟動(dòng)信息的實(shí)例講解,以后還會對VB.NET很多問題進(jìn)行講解,希望即時(shí)關(guān)注。
【編輯推薦】