home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / axnteven / frmlog.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-03-29  |  10.1 KB  |  335 lines

  1. VERSION 5.00
  2. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.0#0"; "COMDLG32.OCX"
  3. Object = "{97746B1E-E2AE-11D2-9A51-00000100C2E6}#1.0#0"; "AxEvntLg.ocx"
  4. Begin VB.Form FrmLog 
  5.    Caption         =   "Event reader"
  6.    ClientHeight    =   7875
  7.    ClientLeft      =   165
  8.    ClientTop       =   450
  9.    ClientWidth     =   10335
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   7875
  12.    ScaleWidth      =   10335
  13.    StartUpPosition =   2  'CenterScreen
  14.    Begin AxEvntLg.AxNTEventLog NTEventLogX 
  15.       Left            =   660
  16.       Top             =   960
  17.       MachineName     =   ""
  18.       SourceName      =   "Application"
  19.       Active          =   0   'False
  20.       BackupFileName  =   ""
  21.       IncludeUserName =   -1  'True
  22.    End
  23.    Begin MSComDlg.CommonDialog OpenDialog 
  24.       Left            =   840
  25.       Top             =   6960
  26.       _ExtentX        =   847
  27.       _ExtentY        =   847
  28.       _Version        =   393216
  29.       DefaultExt      =   "*.evt"
  30.       Filter          =   "Event log (*.evt)|*.evt"
  31.    End
  32.    Begin VB.Frame Frame1 
  33.       Height          =   75
  34.       Left            =   0
  35.       TabIndex        =   8
  36.       Top             =   0
  37.       Width           =   10275
  38.    End
  39.    Begin VB.ListBox lbxEvents 
  40.       BeginProperty Font 
  41.          Name            =   "Courier New"
  42.          Size            =   9
  43.          Charset         =   0
  44.          Weight          =   400
  45.          Underline       =   0   'False
  46.          Italic          =   0   'False
  47.          Strikethrough   =   0   'False
  48.       EndProperty
  49.       Height          =   6360
  50.       Left            =   0
  51.       TabIndex        =   0
  52.       Top             =   360
  53.       Width           =   10155
  54.    End
  55.    Begin VB.Label Label7 
  56.       Caption         =   "Computer"
  57.       BeginProperty Font 
  58.          Name            =   "MS Sans Serif"
  59.          Size            =   8.25
  60.          Charset         =   0
  61.          Weight          =   700
  62.          Underline       =   0   'False
  63.          Italic          =   0   'False
  64.          Strikethrough   =   0   'False
  65.       EndProperty
  66.       Height          =   255
  67.       Left            =   9000
  68.       TabIndex        =   7
  69.       Top             =   120
  70.       Width           =   915
  71.    End
  72.    Begin VB.Label Label6 
  73.       Caption         =   "User"
  74.       BeginProperty Font 
  75.          Name            =   "MS Sans Serif"
  76.          Size            =   8.25
  77.          Charset         =   0
  78.          Weight          =   700
  79.          Underline       =   0   'False
  80.          Italic          =   0   'False
  81.          Strikethrough   =   0   'False
  82.       EndProperty
  83.       Height          =   255
  84.       Left            =   8160
  85.       TabIndex        =   6
  86.       Top             =   120
  87.       Width           =   615
  88.    End
  89.    Begin VB.Label Label5 
  90.       Caption         =   "Event"
  91.       BeginProperty Font 
  92.          Name            =   "MS Sans Serif"
  93.          Size            =   8.25
  94.          Charset         =   0
  95.          Weight          =   700
  96.          Underline       =   0   'False
  97.          Italic          =   0   'False
  98.          Strikethrough   =   0   'False
  99.       EndProperty
  100.       Height          =   255
  101.       Left            =   5460
  102.       TabIndex        =   5
  103.       Top             =   120
  104.       Width           =   675
  105.    End
  106.    Begin VB.Label Label4 
  107.       Caption         =   "Date"
  108.       BeginProperty Font 
  109.          Name            =   "MS Sans Serif"
  110.          Size            =   8.25
  111.          Charset         =   0
  112.          Weight          =   700
  113.          Underline       =   0   'False
  114.          Italic          =   0   'False
  115.          Strikethrough   =   0   'False
  116.       EndProperty
  117.       Height          =   255
  118.       Left            =   780
  119.       TabIndex        =   4
  120.       Top             =   120
  121.       Width           =   495
  122.    End
  123.    Begin VB.Label Label3 
  124.       Caption         =   "Category"
  125.       BeginProperty Font 
  126.          Name            =   "MS Sans Serif"
  127.          Size            =   8.25
  128.          Charset         =   0
  129.          Weight          =   700
  130.          Underline       =   0   'False
  131.          Italic          =   0   'False
  132.          Strikethrough   =   0   'False
  133.       EndProperty
  134.       Height          =   255
  135.       Left            =   4440
  136.       TabIndex        =   3
  137.       Top             =   120
  138.       Width           =   855
  139.    End
  140.    Begin VB.Label Label2 
  141.       Caption         =   "Source"
  142.       BeginProperty Font 
  143.          Name            =   "MS Sans Serif"
  144.          Size            =   8.25
  145.          Charset         =   0
  146.          Weight          =   700
  147.          Underline       =   0   'False
  148.          Italic          =   0   'False
  149.          Strikethrough   =   0   'False
  150.       EndProperty
  151.       Height          =   255
  152.       Left            =   3480
  153.       TabIndex        =   2
  154.       Top             =   120
  155.       Width           =   675
  156.    End
  157.    Begin VB.Label Label1 
  158.       Caption         =   "Time"
  159.       BeginProperty Font 
  160.          Name            =   "MS Sans Serif"
  161.          Size            =   8.25
  162.          Charset         =   0
  163.          Weight          =   700
  164.          Underline       =   0   'False
  165.          Italic          =   0   'False
  166.          Strikethrough   =   0   'False
  167.       EndProperty
  168.       Height          =   255
  169.       Left            =   1740
  170.       TabIndex        =   1
  171.       Top             =   120
  172.       Width           =   495
  173.    End
  174.    Begin VB.Menu mniFile 
  175.       Caption         =   "File"
  176.       Begin VB.Menu mniApplication 
  177.          Caption         =   "Application"
  178.          Checked         =   -1  'True
  179.       End
  180.       Begin VB.Menu mniSecurity 
  181.          Caption         =   "Security"
  182.       End
  183.       Begin VB.Menu mniSystem 
  184.          Caption         =   "System"
  185.       End
  186.       Begin VB.Menu Divider1 
  187.          Caption         =   "-"
  188.       End
  189.       Begin VB.Menu mniBackup 
  190.          Caption         =   "Backup"
  191.       End
  192.       Begin VB.Menu mniOpen 
  193.          Caption         =   "Open"
  194.       End
  195.       Begin VB.Menu mniClear 
  196.          Caption         =   "Clear"
  197.       End
  198.       Begin VB.Menu Divider2 
  199.          Caption         =   "-"
  200.       End
  201.       Begin VB.Menu mniConnect 
  202.          Caption         =   "Connect"
  203.       End
  204.       Begin VB.Menu mniExit 
  205.          Caption         =   "Exit"
  206.       End
  207.    End
  208.    Begin VB.Menu mniView 
  209.       Caption         =   "View"
  210.       Begin VB.Menu mniNewest 
  211.          Caption         =   "Newest First"
  212.          Checked         =   -1  'True
  213.       End
  214.       Begin VB.Menu mniOldest 
  215.          Caption         =   "Oldest First"
  216.       End
  217.    End
  218. Attribute VB_Name = "FrmLog"
  219. Attribute VB_GlobalNameSpace = False
  220. Attribute VB_Creatable = False
  221. Attribute VB_PredeclaredId = True
  222. Attribute VB_Exposed = False
  223. Private Function GetString(ByVal Obj As IEventItem) As String
  224.   S = Format(Obj.TimeWritten, "dd-mmm-yyyy hh:nn:ss ")
  225.   S = S + Format(Obj.SourceName, "@@@@@@@@@@@@@@@@@ ")
  226.   S = S + Format(Obj.EventCategory, "         0   ")
  227.   If Obj.EventId < 0 Then J = 65536 - (Abs(Obj.EventId) Mod 65536) Else J = Obj.EventId Mod 65536
  228.   S = S + Format(J, "00000")
  229.   S = S + Format(Obj.UserName, " @@@@@@@@@@@@@@@@@@@@@@@ ")
  230.   S = S + Format(Obj.ComputerName, " @@@@@@@@@@ ")
  231.   GetString = S
  232. End Function
  233. Private Sub RereadEventLog()
  234.   On Error GoTo ErrorHandler
  235.   If Not NTEventLogX.BackupFileName = "" Then Caption = NTEventLogX.BackupFileName Else Caption = "Event reader " + NTEventLogX.MachineName + "\" + NTEventLogX.SourceName
  236.   lbxEvents.Clear
  237.   NTEventLogX.Active = False
  238.   NTEventLogX.Active = True
  239.   For i = 0 To NTEventLogX.Count - 1
  240.     Set Obj = NTEventLogX.Objects(i)
  241.     S = GetString(Obj)
  242.     If mniOldest.Checked Then lbxEvents.AddItem (S) Else lbxEvents.AddItem S, 0
  243.   Next i
  244. ExitProc:
  245.   Exit Sub
  246. ErrorHandler:
  247.   MsgBox (Err.Description)
  248.   Resume ExitProc
  249. End Sub
  250. Private Sub Form_Load()
  251.   NTEventLogX.MachineName = NTEventLogX.GetPrimaryDomainServerName
  252.   NTEventLogX.Active = True
  253.   RereadEventLog
  254. End Sub
  255. Private Sub Form_Resize()
  256.   lbxEvents.Width = Width - 100
  257.   lbxEvents.Height = Height - 950
  258.   Frame1.Width = Width - 6
  259. End Sub
  260. Private Sub List1_Click()
  261. End Sub
  262. Private Sub Outline1_Click()
  263. End Sub
  264. Private Sub lbxEvents_DblClick()
  265.   FrmDetails.Show (vbModal)
  266. End Sub
  267. Private Sub mniApplication_Click()
  268.   mniApplication.Checked = True
  269.   mniSystem.Checked = False
  270.   mniSecurity.Checked = False
  271.   NTEventLogX.SourceName = "Application"
  272.   RereadEventLog
  273. End Sub
  274. Private Sub mniBackup_Click()
  275.   OpenDialog.ShowSave
  276.   If Not OpenDialog.filename = "" Then
  277.     NTEventLogX.BackupFileName = OpenDialog.filename
  278.     NTEventLogX.BackupEventLog
  279.     NTEventLogX.BackupFileName = ""
  280.   End If
  281. End Sub
  282. Private Sub mniClear_Click()
  283.   On Error GoTo ErrorHandler
  284.   If MsgBox("Are you sure to delete all items from event log ?", vbOKCancel, "Confirmation") = vbCancel Then Exit Sub
  285.   NTEventLogX.Clear
  286.   RereadEventLog
  287. ExitProc:
  288.   Exit Sub
  289. ErrorHandler:
  290.   MsgBox (Err.Description)
  291.   Resume ExitProc
  292. End Sub
  293. Private Sub mniConnect_Click()
  294.   FrmConnect.Show (vbModal)
  295.   If Not NTEventLogX.Active Then RereadEventLog
  296. End Sub
  297. Private Sub mniExit_Click()
  298.   Unload FrmLog
  299. End Sub
  300. Private Sub mniNewest_Click()
  301.   mniNewest.Checked = True
  302.   mniOldest.Checked = False
  303.   RereadEventLog
  304. End Sub
  305. Private Sub mniOldest_Click()
  306.   mniNewest.Checked = False
  307.   mniOldest.Checked = True
  308.   RereadEventLog
  309. End Sub
  310. Private Sub mniOpen_Click()
  311.   OpenDialog.ShowOpen
  312.   If Not OpenDialog.filename = "" Then
  313.     NTEventLogX.BackupFileName = OpenDialog.filename
  314.     RereadEventLog
  315.     NTEventLogX.BackupFileName = ""
  316.   End If
  317. End Sub
  318. Private Sub mniSecurity_Click()
  319.   mniApplication.Checked = False
  320.   mniSystem.Checked = False
  321.   mniSecurity.Checked = True
  322.   NTEventLogX.SourceName = "Security"
  323.   RereadEventLog
  324. End Sub
  325. Private Sub mniSystem_Click()
  326.   mniApplication.Checked = False
  327.   mniSystem.Checked = True
  328.   mniSecurity.Checked = False
  329.   NTEventLogX.SourceName = "System"
  330.   RereadEventLog
  331. End Sub
  332. Private Sub NTEventLogX_OnChange()
  333.   MsgBox ("Event log changed!")
  334. End Sub
  335.