|
|
发表于 2005-5-29 07:44:36| 字数 1,288| - 中国–北京–北京–西城区 联通
|
显示全部楼层
1.Start Microsoft Visual Basic. Open a new ActiveX DLL project. This will add Class1 to the new project.
2.Change the Name property of Class1 to "Logging" .
3.From the Project menu, click Project1 Properties.
4.Change the Name of the Project to "AppMessages".
5.Add the following code to the Logging class:
Public Enum eLogModes
mLogAuto = 0
mLogOff = 1
mLogToFile = 2
mLogToNT = 3
mLogOverwrite = &H10
mLogThreadID = &H20
End Enum
Public Sub StartLog(logTarget As String, logMode As eLogModes)
App.StartLogging logTarget, logMode
End Sub
Public Sub AddLogEvent(LogBuffer As String, EventType As _
LogEventTypeConstants)
App.LogEvent LogBuffer, EventType
End Sub
6.From the File menu, click Make AppMessage.DLL
7.From the File menu, click New project. Click Yes to Save the AppMessage source code for later use.
Select Standard EXE. Click OK.
From the Project menu, click References.
Turn on the reference to "AppMessages." Click OK.
To Form1, add the following code:
Private Sub Form_Load()
Dim t As New AppMessages.Logging
t.StartLog "C:\TEMP\Test.log", mLogToFile
t.AddLogEvent "Form Loaded", vbLogEventTypeInformation
Set t = Nothing
End Sub
8.From the Run menu, click Start. A new file "Test.log" will be created and placed into the C:\TEMP folder. This file will contain the information:
"Information Application C:\TEMP\Test.log: Thread ID: -316429 ,Logged: Form Loaded"
[ Last edited by appxp on 2005-5-29 at 07:51 ] |
|