Xojo Conferences
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/Win/WMI/WMI Query
Function:
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 Tue, 22th Jun 2015.
Project "WMI Query.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 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:

Feedback, Comments & Corrections

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




Links
MBS Xojo Plugins