Xojo Conferences

Platforms to show: All Mac Windows Linux Cross-Platform

/Win/WMI/WMI Network Test
Required plugins for this example: MBS Win Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Win/WMI/WMI Network Test
This example is the version from Tue, 22th Jun 2015.
Project "WMI Network Test.rbp"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
EventHandler Sub Open() // required for Windows 8.1 call WindowsWMIMBS.InitSecurity(false) End EventHandler
End Class
Class Window1 Inherits Window
Control Label1 Inherits Label
ControlInstance Label1 Inherits Label
End Control
Control Label2 Inherits Label
ControlInstance Label2 Inherits Label
End Control
Control PropertyList Inherits Listbox
ControlInstance PropertyList Inherits Listbox
End Control
Control Label3 Inherits Label
ControlInstance Label3 Inherits Label
End Control
Control Label4 Inherits Label
ControlInstance Label4 Inherits Label
End Control
Control Label5 Inherits Label
ControlInstance Label5 Inherits Label
End Control
Control ExitButton Inherits PushButton
ControlInstance ExitButton Inherits PushButton
EventHandler Sub Action() Quit End EventHandler
End Control
Control PropertyValue Inherits Listbox
ControlInstance PropertyValue Inherits Listbox
End Control
Control NextItemButton Inherits PushButton
ControlInstance NextItemButton Inherits PushButton
EventHandler Sub Action() Dim q As String = "SELECT * FROM Win32_NetworkAdapterConfiguration" Dim p, s, v As String Dim i, t As Integer Dim aa() As String If Not wmi.NextItem Then ' Will fail the first time, or if the end of the set of objects has been reached -- ' so (re)issue the query. If Not wmi.query("WQL",q) Then MsgBox "WMI Query Failed." Quit Else ' query succeeded -- try for first item If Not wmi.NextItem Then ' did not get one MsgBox "WMI Get Next Item Failed." Quit End If End If End If ' we got an item ... ' clear the output lists PropertyType.DeleteAllRows PropertyValue.DeleteAllRows ' Go through the list of property names, getting the type and value of each property For i = 0 to PropertyList.ListCount - 1 p = PropertyList.List(i) ' property name t = wmi.GetPropertyType(p) ' type as integer s = wmi.GetPropertyTypeString(p) ' type as string PropertyType.Addrow(Str(t) + " (" + s + ")") Select Case t Case 1 ' Nil v = "" PropertyValue.AddRow(v) Case 8200 ' string array v = "" aa = wmi.GetProperty(p) ' ''''' not yet implemented v = Join(aa,",") PropertyValue.Addrow(v) Case Else ' integer, boolean, string -- get string form v = wmi.GetPropertyString(p) PropertyValue.AddRow(v) End Select Next End EventHandler
End Control
Control PropertyType Inherits Listbox
ControlInstance PropertyType Inherits Listbox
End Control
EventHandler Sub Open() ' Create the WMI object wmi = New WindowsWMIMBS If Not wmi.ConnectServer("root\cimv2") Then MsgBox "Failed to connect to WMI server." Quit End If MsgBox "Connected to WMI server" ' Now wait for the user to click the "Next Item" button End EventHandler
Property wmi As WindowsWMIMBS
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
End Project

See also:

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS Win Plugin.

MBS Xojo Chart Plugins