Private Sub cmdWriteEventLog_Click()
Dim enmLogType As enmLogType
Dim abytDataBuffer() As Byte
Dim astrEventText() As String
' Other DIMs not shown
If optLocalRemote(0).Value = True Then
strServerName$ = ""
Else
strServerName$ = _
Trim$(txtRemoteMachine.Text)
End If
strAppName = APP_NAME
strEventLogName = cboLogName.List _
(Me.cboLogName.ListIndex)
abytDataBuffer = _
Me.txtEventData.Text
ReDim astrEventText (0 To 0) As String
astrEventText(0) = Me.txtEventString.Text
strAppNameMunged = GetAppNameMunged _
(strEventLogName, strAppName)
If optErrorLevel(0).Value = True Then
enmLogType = LogInfo
ElseIf optErrorLevel(1). Value = True Then
enmLogType = LogWarning
ElseIf optErrorLevel(2). Value = True Then
enmLogType = LogError
End If
lngEventID = CLng(cboEventID.ItemData _
(Me.cboEventID.ListIndex))
lngCategory = CLng(Me.cboCategory.List _
(Me.cboCategory.ListIndex))
m_objEvntLog.EventDataBuffer = abytDataBuffer
m_objEvntLog.EventCategory = lngCategory
If UCase$(Trim$ (strEventLogName)) = _
"SECURITY" Then
MsgBox "Only the LocalSystem acct can " & _
"write to the security log"
Else
On Error GoTo WriteLog_Err
m_objEvntLog.WriteEventLog strServerName, _
strAppNameMunged, enmLogType, _
lngEventID, strEventLogName, astrEventText
End If
Exit Sub
WriteLog_Err:
' MsgBox with error info
End Sub
|