Platforms to show: All Mac Windows Linux Cross-Platform
/Win/WMI/WMI Recent Windows Events
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 Fri, 12th Aug 2021.
Project "WMI Recent Windows Events.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 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:
- /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 Query
- /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.