Platforms to show: All Mac Windows Linux Cross-Platform
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 Query
This example is the version from Wed, 16th Nov 2021.
Project "WMI Query.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
Sub Constructor()
// required for Windows 8.1 or later
Call WindowsWMIMBS.InitSecurity(False)
End Sub
End Class
Class Window1 Inherits Window
Control query Inherits TextField
ControlInstance query Inherits TextField
End Control
Control List Inherits Listbox
ControlInstance List Inherits Listbox
End Control
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action()
run
End EventHandler
End Control
Control PopupMenu1 Inherits PopupMenu
ControlInstance PopupMenu1 Inherits PopupMenu
EventHandler Sub Change()
if me.ListIndex>=0 then
query.text=me.text
PushButton1.Push
end if
End EventHandler
End Control
Control PopupMenu2 Inherits PopupMenu
ControlInstance PopupMenu2 Inherits PopupMenu
EventHandler Sub Change()
if TargetWin32 then
w=new WindowsWMIMBS
if w.ConnectServer("root\"+PopupMenu2.text) then
'MsgBox "Connected"
run
else
MsgBox "ConnectServer: fail"+EndOfLine+"Lasterror: "+str(w.Lasterror)
end if
end if
End EventHandler
End Control
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
EventHandler Sub Open()
if TargetWin32 then
w=new WindowsWMIMBS
if w.ConnectServer("root\"+PopupMenu2.text) then
'MsgBox "Connected"
else
MsgBox "ConnectServer: fail"+EndOfLine+"Lasterror: "+str(w.Lasterror)
end if
else
MsgBox "This example is for Windows only."
end if
End EventHandler
Function St(v as Variant) As string
if v.IsArray then
dim s() as string = v
Return Join(s,", ")
end if
Return v.StringValue
Exception t as TypeMismatchException
// ignore
End Function
Sub run()
list.DeleteAllRows
if w.query("WQL",query.text) then
'MsgBox "query: ok"
while w.NextItem
dim s(-1) as string = w.GetNames
for each t as string in s
List.AddRow t
List.Cell(List.LastIndex,1)=st(w.GetProperty(t))
List.Cell(List.LastIndex,2)=hex(w.GetPropertyType(t))+" "+w.GetPropertyTypeString(t)
next
wend
else
MsgBox "query: fail"+EndOfLine+"Lasterror: "+str(w.Lasterror)
end if
End Sub
Property w 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:
- /Win/WMI/WMI File Events
- /Win/WMI/WMI HDD Info
- /Win/WMI/WMI Network Test
- /Win/WMI/WMI Process CPU usage
- /Win/WMI/WMI Process Creation Events
- /Win/WMI/WMI Process Creation Events via Remote
- /Win/WMI/WMI Processor
- /Win/WMI/WMI Recent Windows Events
- /Win/WMI/WMI Recent Windows Events Web
- /Win/WMI/WMI Wireless LAN Signal Strength
The items on this page are in the following plugins: MBS Win Plugin.