在过去的几个月里,我一直在使用 ClamAV 创建一个防病毒应用程序,该应用程序运行良好。
我有另一个软件可以检测机器中安装的安全、间谍软件和防火墙。在运行扫描时,它会检测到已安装在我的机器上的 ESAT Smart Security 8.0,而我的防病毒软件不在列表中。在进行一些研究时,我发现这段代码可以检测到机器中是否存在防病毒软件。
ManagementObjectSearcher managementObjectSearcher = new ManagementObjectSearcher(@"\\MyMachineName\root\SecurityCenter2", "SELECT * FROM AntivirusProduct");
ManagementObjectCollection objectCollection = managementObjectSearcher.Get();
string DisplayName = String.Empty;
if (managementObjectSearcher.Get().Count > 0)
{
foreach (ManagementObject managementObject in managementObjectSearcher.Get())
{
DisplayName = managementObject["displayName"].ToString();
}
}
现在我确实相信,为了使我的应用程序看起来像一个防病毒软件,我必须在 SecurityCenter2 或 WMI 中输入一些条目。我尝试了以下代码来实现它
public static void RegisterAsAntivirus()
{
string computer = Environment.MachineName;
string wmipath = @"\\" + computer + @"\root\SecurityCenter2";
ManagementScope oScope = new ManagementScope(wmipath);
oScope.Connect();
ManagementPath oPath = new ManagementPath("AntivirusProduct");
ObjectGetOptions oGetOp = new ObjectGetOptions();
ManagementClass oProcess = new ManagementClass(oScope, oPath, oGetOp);
PropertyDataCollection p = oProcess.Properties;
// Obtain in-parameters for the method
oProcess.SetPropertyValue("displayName", "antivirusname");
oProcess.SetPropertyValue("instanceGuid", "guid");
oProcess.SetPropertyValue("pathToSignedProductExe", @"path");
oProcess.SetPropertyValue("pathToSignedReportingExe", "");
oProcess.SetPropertyValue("productState", 266240);
oProcess.Put();
}
但即使是上面的代码行也不适合我。而且我还处于同一水平。在这方面的任何帮助将不胜感激。
我的机器在 Windows 7 上运行,c# 是我的编程语言。