procedure TfrmMain.GetWin32_NTLogEventInfo;
const
WbemUser = '
';
WbemPassword = '
';
WbemComputer = '
localhost';
wbemFlagForwardOnly = $00000020;
var
FSWbemLocator: OLEVariant;
FWMIService: OLEVariant;
FWbemObjectSet: OLEVariant;
FWbemObject: OLEVariant;
oEnum: IEnumvariant;
iValue: LongWord;
Insertion:
array of String;
Data:
array of Byte;
I: integer;
begin;
FSWbemLocator := CreateOleObject('
WbemScripting.SWbemLocator');
FWMIService := FSWbemLocator.ConnectServer(WbemComputer, '
root\CIMV2',
WbemUser, WbemPassword);
FWbemObjectSet := FWMIService.ExecQuery
('
SELECT * FROM Win32_NTLogEvent Where Logfile=''
Application''
', '
WQL',
wbemFlagForwardOnly);
// Wird hier das Log angegeben?!
oEnum := IUnknown(FWbemObjectSet._NewEnum)
as IEnumvariant;
while oEnum.Next(1, FWbemObject, iValue) = 0
do
begin
try
if not VarIsNull(FWbemObject.Data)
then
if not VarIsNull(FWbemObject.InsertionStrings)
then
begin
Data := FWbemObject.Data;
Insertion := FWbemObject.InsertionStrings;
for I := VarArrayLowBound(Data, 1)
to VarArrayLowBound(Data, 1)
do
MLog.Lines.Add('
Code ' + IntToStr(Data[I]) + '
:' + Insertion[I]);
end;
except
on E:
Exception do
begin
MessageDlg(E.
Message, mtError, [mbOK], 0);
end;
end;
FWbemObject := Unassigned;
end;
end;