home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 February / Chip_2004-02_cd1.bin / zkuste / konfig / download / msic / Help / Int / MiTeC_EventLogNT.int < prev    next >
Text File  |  2003-08-26  |  4KB  |  136 lines

  1. {*******************************************************}
  2. {                                                       }
  3. {       MiTeC System Information Component              }
  4. {        Windows NT Event Log Enumeration               }
  5. {           version 8.3 for Delphi 5,6,7                }
  6. {                                                       }
  7. {       Copyright ⌐ 1997,2003 Michal Mutl               }
  8. {                                                       }
  9. {*******************************************************}
  10.  
  11. {$INCLUDE MITEC_DEF.INC}
  12.  
  13.  
  14. unit MiTeC_EventLogNT;
  15.  
  16. interface
  17.  
  18. uses Windows, Classes, SysUtils;
  19.  
  20. const
  21.   BUFFER_SIZE = 4096;
  22.  
  23. // Defines for the READ flags for Eventlogging
  24.   EVENTLOG_SEQUENTIAL_READ =  $0001;
  25.   EVENTLOG_SEEK_READ       =  $0002;
  26.   EVENTLOG_FORWARDS_READ   =  $0004;
  27.   EVENTLOG_BACKWARDS_READ  =  $0008;
  28.  
  29. // The types of events that can be logged.
  30.  
  31.   EVENTLOG_SUCCESS          = $0000;
  32.   EVENTLOG_ERROR_TYPE       = $0001;
  33.   EVENTLOG_WARNING_TYPE     = $0002;
  34.   EVENTLOG_INFORMATION_TYPE = $0004;
  35.   EVENTLOG_AUDIT_SUCCESS    = $0008;
  36.   EVENTLOG_AUDIT_FAILURE    = $0010;
  37.  
  38.  
  39. // Defines for the WRITE flags used by Auditing for paired events
  40. // These are not implemented in Product 1
  41.  
  42.   EVENTLOG_START_PAIRED_EVENT    = $0001;
  43.   EVENTLOG_END_PAIRED_EVENT      = $0002;
  44.   EVENTLOG_END_ALL_PAIRED_EVENTS = $0004;
  45.   EVENTLOG_PAIRED_EVENT_ACTIVE   = $0008;
  46.   EVENTLOG_PAIRED_EVENT_INACTIVE = $0010;
  47.  
  48. type
  49.   PSID = Pointer;
  50.  
  51.   _EVENTLOGRECORD = record
  52.     Length: DWORD;
  53.     Reserved: DWORD;
  54.     RecordNumber: DWORD;
  55.     TimeGenerated: DWORD;
  56.     TimeWritten: DWORD;
  57.     EventID: DWORD;
  58.     EventType: WORD;
  59.     NumStrings: WORD;
  60.     EventCategory: WORD;
  61.     ReservedFlags: WORD;
  62.     ClosingRecordNumber: DWORD;
  63.     StringOffset: DWORD;
  64.     UserSidLength: DWORD;
  65.     UserSidOffset: DWORD;
  66.     DataLength: DWORD;
  67.     DataOffset: DWORD;
  68.     {SourceName: PChar;
  69.     Computername: PChar;
  70.     UserSid: PSID;
  71.     Strings: PChar;
  72.     Data: PChar;
  73.     Pad: PChar;
  74.     Length: DWORD;}
  75.   end;
  76.  
  77.   PEVENTLOGRECORD = ^EVENTLOGRECORD;
  78.   EVENTLOGRECORD = _EVENTLOGRECORD;
  79.  
  80.   TEventLogType = (elApplication, elSystem, elSecurity);
  81.  
  82.   TEventType = (etError, etWarning, etInformation, etAuditSuccess, etAuditFailure);
  83.  
  84.   PLogRecord = ^TLogRecord;
  85.   TLogRecord = record
  86.     EventType: TEventType;
  87.     DateTime: TDateTime;
  88.     Source: string;
  89.     Category: string;
  90.     EventID: Cardinal;
  91.     Username: string;
  92.     Domain: string;
  93.     Computer: string;
  94.     Description: string;
  95.     BinaryData: string;
  96.     CharData: string;
  97.   end;
  98.  
  99.   TEventLog = class(TPersistent)
  100.   private
  101.     FType: TEventLogType;
  102.     FRecords: TStringList;
  103.     FMachine: string;
  104.  
  105.     procedure RetrieveLog(AMachine: string; AType: TEventLogType);
  106.     procedure FreeList(var AList: TStringList);
  107.  
  108.     function GetRecCount: DWORD;
  109.     function GetRecord(Index: DWORD): PLogRecord;
  110.   public
  111.     constructor Create;
  112.     destructor Destroy; override;
  113.     procedure Refresh;
  114.  
  115.     property Machine: string read FMachine write FMachine;
  116.     property LogType: TEventLogType read FType write FType;
  117.     property RecordCount: DWORD read GetRecCount;
  118.     property LogRecords[Index: DWORD]: PLogRecord read GetRecord;
  119.   end;
  120.  
  121. const
  122.   EventLogTypes: array[elApplication..elSecurity] of string = ('Application', 'System', 'Security');
  123.   EventTypes: array[etError..etAuditFailure] of string = ('Error', 'Warning', 'Information', 'AuditSuccess', 'AuditFailure');
  124.  
  125.   rkEventLog = {HKEY_LOCAL_MACHINE\}'SYSTEM\CurrentControlSet\Services\EventLog';
  126.  
  127.   rvEventMessageFile = 'EventMessageFile'; // Path to the message resource file that contains the event format strings.
  128.   rvTypesSupported = 'TypesSupported'; //The types of events this source can generate.
  129.   rvCategoryMessageFile = 'CategoryMessageFile'; //Path to the message resource file that has the descriptive strings for the source categories.
  130.   rvCategoryCount = 'CategoryCount'; // The number of categories described in the CategoryMessageFile.
  131.   rvParameterMessageFile = 'ParameterMessageFile'; //Insert parameter descriptive strings.
  132.  
  133.  
  134. implementation
  135.  
  136.