The next code show how detect if an antivirus software is installed in Windows using Delphi Prism (Oxygene) and the WMI.
uses System, System.Management, System.Text; type ConsoleApp = class private class method AntivirusInstalled() : Boolean; public class method Main; end; implementation class method ConsoleApp.Main; begin var returnCode : Boolean := AntivirusInstalled(); Console.WriteLine("Antivirus Installed " + returnCode.ToString()); Console.WriteLine(); Console.Read(); end; class method ConsoleApp.AntivirusInstalled() : Boolean; begin var wmipathstr :string := "\\" + Environment.MachineName + "\root\SecurityCenter";//since windows vista you must use the SecurityCenter2 namespace try var searcher : ManagementObjectSearcher := New ManagementObjectSearcher(wmipathstr, "SELECT * FROM AntivirusProduct"); var instances : ManagementObjectCollection := searcher.Get(); result:=(instances.Count > 0); except on E: Exception do begin Console.WriteLine(e.Message); Result:=False; end; end; end;
May 12, 2018 at 3:02 am
thanku for sharing