#Region Project Attributes
#MainFormWidth: 600
#MainFormHeight: 600
#End Region
#AdditionalJar: jna-5.2.0
#AdditionalJar: jna-platform-5.2.0
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Public timer1 As Timer
Dim EventLogIterator As JavaObject
End Sub
Sub AppStart (form1 As Form,Args() As String)
MainForm = form1
MainForm.show
timer1.Initialize("timers1",5000)
timer1.Enabled=True
EventLogIterator.InitializeNewInstance("com.sun.jna.platform.win32.Advapi32Util.EventLogIterator", Array("application"))
Do While EventLogIterator.RunMethod("hasNext", Null)
Dim record As JavaObject = EventLogIterator.RunMethod("next", Null)
Log($"ID: ${record.RunMethod("getEventId", Null)}, type: ${record.RunMethod("getType", Null)}, source: ${record.RunMethod("getSource", Null)}"$)
Dim amap() As String=record.RunMethod("getStrings", Null)
For i=0 To amap.length-1
Log(amap(i))
Next
Loop
End Sub
Sub timers1_tick
timer1.Enabled=False
Log("read events...")
'EventLogIterator.InitializeContext /// That will help if was android... but we are talking about b4j..
Dim haveanew As Boolean = EventLogIterator.RunMethod("hasNext", Null)
Log(haveanew)
If haveanew=True Then
Dim record As JavaObject = EventLogIterator.RunMethod("next", Null)
Log($"ID: ${record.RunMethod("getEventId", Null)}, type: ${record.RunMethod("getType", Null)}, source: ${record.RunMethod("getSource", Null)}"$)
Dim amap() As String=record.RunMethod("getStrings", Null)
For i=0 To amap.length-1
Log(amap(i))
Next
End If
timer1.Enabled=True
End Sub
'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
Return True
End Sub