Xojo Conferences
MBSSep2018MunichDE
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/Win/WMI/WMI Recent Windows Events
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 Recent Windows Events
This example is the version from Tue, 22th Jun 2015.
Project "WMI Recent Windows Events.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 List Inherits Listbox
ControlInstance List Inherits Listbox
End Control
EventHandler Sub Open() if TargetWin32 then // init and connect w=new WindowsWMIMBS if w.ConnectServer("root\cimv2") then // query number of records if w.query("WQL","Select * from Win32_NTEventLogFile Where LogFileName = 'Application'") then if w.NextItem then dim NumberOfRecords as integer = w.GetPropertyInteger("NumberOfRecords") dim last10 as integer = 0 if NumberOfRecords > 10 then last10 = NumberOfRecords - 10 // now get the newest 10 for i as integer = last10 to NumberOfRecords-1 if w.Query("WQL","Select * from Win32_NTLogEvent Where LogFile = 'Application' AND RecordNumber =" +str(i)) then if w.NextItem then list.AddRow w.GetPropertyString("ComputerName") List.Cell(List.LastIndex,1)=str(w.GetPropertyInteger("EventCode")) List.Cell(List.LastIndex,2)=w.GetPropertyString("Message") end if end if next else MsgBox "NextItem: fail"+EndOfLine+"Lasterror: "+str(w.Lasterror) end if else MsgBox "query: fail"+EndOfLine+"Lasterror: "+str(w.Lasterror) end if else MsgBox "ConnectServer: fail"+EndOfLine+"Lasterror: "+str(w.Lasterror) end if else MsgBox "This example is for Windows only." end if End EventHandler
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 FileMaker blog