uses {..,} ComObj,
ActiveX;
procedure TForm1.Button1Click(Sender: TObject);
var
SWbem,
SWbemCon,
SWbemQuery,
objVar : OleVariant;
szWQL :
String;
pFetched : LongInt;
unknown : IUnknown;
enumUnk : IEnumUnknown;
Counter : Integer;
boIsWinXP: Boolean;
const
ARR_NAMESPACE :
Array[False..True]
of String = ('
SecurityCenter2',
//Vista/Win7
'
SecurityCenter');
//WinXP
procedure Display(szValue:
String = '
'; szData :
String = '
');
begin
Form1.Canvas.TextOut(20 , Counter, szValue);
Form1.Canvas.TextOut(200, Counter, szData );
inc(Counter, 17);
end;
begin
boIsWinXP := False;
//get win version
Canvas.FillRect(Rect(0,0,form1.Width,form1.Height));
Counter := 20;
CoInitialize(
nil);
try
SWbem := CreateOleObject('
WbemScripting.SWbemLocator');
// strServer, strNamespace, strUser, strPassword, strLocale, strAuthority,
// iSecurityFlags, objwbemNamedValueSet
SWbemCon := SWbem.ConnectServer('
', '
root\'+ARR_NAMESPACE[boIsWinXP], '
', '
', '
');
//szWQL := 'Select * from AntiSpywareProduct'; // not in WinXP
szWQL := '
Select * from AntiVirusProduct';
SWbemQuery := SWbemCon.ExecQuery(szWQL,'
WQL', 48);
unknown := SWbemQuery._NewEnum;
unknown.QueryInterface(IEnumVariant, enumUnk);
VarClear(objVar);
OleCheck(enumUnk.Next( 1, objVar, @pFetched ));
if (pFetched <> 0)
then begin
if boIsWinXP
then begin
Display('
companyName:' , VarToStr(objVar.companyName));
Display('
displayName:' , VarToStr(objVar.displayName));
Display('
enableOnAccessUIMd5Hash:' , VarToStr(objVar.enableOnAccessUIMd5Hash));
Display('
enableOnAccessUIParameters:', VarToStr(objVar.enableOnAccessUIParameters));
Display('
instanceGuid:' , VarToStr(objVar.instanceGuid));
Display('
onAccessScanningEnabled:' , VarToStr(objVar.onAccessScanningEnabled));
Display('
pathToEnableOnAccessUI:' , VarToStr(objVar.pathToEnableOnAccessUI));
Display('
pathToUpdateUI:' , VarToStr(objVar.pathToUpdateUI));
Display('
productUptoDate:' , VarToStr(objVar.productUptoDate));
Display('
updateUIMd5Hash:' , VarToStr(objVar.updateUIMd5Hash));
Display('
updateUIParameters:' , VarToStr(objVar.updateUIParameters));
Display('
versionNumber:' , VarToStr(objVar.versionNumber));
end else begin
Display('
displayName:' , VarToStr(objVar.displayName));
Display('
instanceGuid:' , VarToStr(objVar.instanceGuid));
Display('
pathToSignedProductExe:' , VarToStr(objVar.pathToSignedProductExe));
Display('
pathToSignedReportingExe:' , VarToStr(objVar.pathToSignedReportingExe));
Display('
productState:' , VarToStr(objVar.productState));
end;
end else
Display('
No supported AV products found...');
Display('
---------------------------------------------');
szWQL := '
Select * from FirewallProduct';
SWbemQuery := SWbemCon.ExecQuery(szWQL,'
WQL', 48);
unknown := SWbemQuery._NewEnum;
unknown.QueryInterface(IEnumVariant, enumUnk);
VarClear(objVar);
OleCheck(enumUnk.Next( 1, objVar, @pFetched ));
if (pFetched <> 0)
then begin
if boIsWinXP
then begin
Display('
Company Name:' , VarToStr(objVar.companyName));
Display('
Display Name:' , VarToStr(objVar.displayName));
Display('
Enabled:' , VarToStr(objVar.enabled));
Display('
enableUIParameters:', VarToStr(objVar.enableUIParameters));
Display('
pathToEnableUI:' , VarToStr(objVar.pathToEnableUI));
Display('
versionNumber:' , VarToStr(objVar.versionNumber));
end else begin
Display('
displayName:' , VarToStr(objVar.displayName));
Display('
instanceGuid:' , VarToStr(objVar.instanceGuid));
Display('
pathToSignedProductExe:' , VarToStr(objVar.pathToSignedProductExe));
Display('
pathToSignedReportingExe:' , VarToStr(objVar.pathToSignedReportingExe));
Display('
productState:' , VarToStr(objVar.productState));
end;
end else
Display('
No supported FW products found...');
finally
CoUnInitialize;
end;
end;