软件开发:创建你自己的Windows安全中心

作者:Fisnik 19岁 瑞典人

文章出处:http://www.codeproject.com/KB/cs/xpsecuritycenter.aspx

我想,许多用户一直想知道如何Windows安全中心的建立。那么,本文中我将演示如何Windows ® XP的安全中心的建立以及它如何工作,等。

简述:

Windows安全中心的Windows ® XP中设计,监测三个不同的安全要点, Windows防火墙的地位, Windows更新设置和防病毒产品的地位。 Windows安全中心已成功地在保护和保持更新每个用户的安全至关重要。

Windows安全中心如何工作?

为了建立自己的Windows安全中心,您应首先了解一个已经工作安全中心工程。 Windows安全中心中的Windows ® XP是第一个微软的安全中心。 Windows安全中心认为信息安全的三个基本要素这样的:

Windows防火墙状态: Windows安全中心认定的Windows防火墙设置通过Windows防火墙的API 。该文件,这些是: hnetcfg.dll 。然而,我们需要的类标识符(的CLSID ) ,其中还必须首先获得提到的Windows防火墙管理类。

第三方防火墙状态: Windows安全中心认定的第三方防火墙通过Windows管理规范( WMI ) ,从安全中心的WMI根路径。

WMI root path: //HOSTNAME/ROOT/SecurityCenter:FirewallProduct

Windows更新状态: Windows安全中心认定的自动更新设置通过Windows注册表。

Registry path: Computer/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/WindowsUpdate/Auto Update/Key: AUOptions

防毒状态: Windows安全中心发现防病毒产品通过Windows管理规范( WMI ) ,从安全中心的WMI根路径。

WMI root path: //HOSTNAME/ROOT/SecurityCenter:AntiVirusProduct

Windows安全中心,事实上,没有这三个安全状况基本职能在其自我。然而,真正的事实是, Windows安全中心不断监测的三个安全要素由于其Windows安全中心服务在后台运行。

说明:该方法在Windows安全中心的Windows ® XP的作品。 Windows安全中心的检查和监测所有三个安全要素。

建立自己的Windows安全中心

现在,最后:我们要建立我们自己的Windows安全中心。

出发的Windows窗体界面,我增加了约8面板控制。我还添加了一些标签, pictureboxes和三个定时器。

新增的Windows防火墙的API

控制Windows防火墙从您的Windows应用程序需要添加一定的引用。

// Adding the Windows Firewall API namespaces using NATUPNPLib; using NETCONLib; using NetFwTypeLib; //现在增加Windows防火墙一些代码 #region Windows Firewall Manager //A reference to the Windows Firewall Manager class. private static NetFwTypeLib.INetFwMgr GetFirewallManager() { // CLSID of the Windows Firewall Manager class const string CLSID_FIREWALL_MANAGER = "{304CE942-6E39-40D8-943A-B913C40C9CD4}"; Type objType = Type.GetTypeFromCLSID(new Guid(CLSID_FIREWALL_MANAGER)); return Activator.CreateInstance(objType) as NetFwTypeLib.INetFwMgr; } // The instance of Windows Firewall Manager private static INetFwMgr netFwMgr = GetFirewallManager(); #endregion #region Monitor Windows Firewall private void WindowsFirewall_Tick(object sender, EventArgs e) { if (netFwMgr.LocalPolicy.CurrentProfile.FirewallEnabled == true) { this.btnTurnOnWinFirewall.Visible = false; this.panel9.Visible = false; this.Firewallpanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(220)))), ((int)(((byte)(228)))), ((int)(((byte)(252))))); this.FirewallStatusIcon.Image = global::XPSecurityCenter.Properties.Resources._51804_34x34_ico_check_f; this.winFirewallStatusTxt.Text = "On"; this.FirewallDescribTxt.Text = "Windows Firewall is protecting your PC from hackers."; } else { this.btnTurnOnWinFirewall.Visible = true; this.panel9.Visible = true; this.Firewallpanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(234)))), ((int)(((byte)(144)))), ((int)(((byte)(111))))); this.FirewallStatusIcon.Image = global::XPSecurityCenter.Properties.Resources._51804_34x34_ico_error_f; this.winFirewallStatusTxt.Text = "Off"; this.FirewallDescribTxt.Text = "The Windows Firewall is turned off and you can be hacked, turn it On again!"; } } #endregion


访问Windows更新设置

现在,我们必须添加代码以监测Windows更新设置。

#region Monitor Windows Updates Settings private void MonitorWindowsUpdate_Tick(object sender, EventArgs e) { RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE/Microsoft/Windows/CurrentVersion/WindowsUpdate/Auto Update/"); int value = (Int32)key.GetValue("AUOptions"); /* Each value [inside the switch ()] below describes a setting property: 1 = The Windows Automatic Update is turned off. 2 = The Windows Automatic Updates still on. But it's using this settings instead: "Check for updates but let me choose whether to download and install them". 3 = The Windows Automatic Updates still on. But it's using this setting instead: "Download updates but let me choose whether to install them". 4 = The Windows Automatic Updates is turned on. */ switch(value) { //If the value=1 then set these properties. //The properties are changed to alerting design, //so the user gets informed. case 1: this.btnTurnONAU.Visible = true; this.panel10.Visible = true; this.automaticUpdatePanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(234)))), ((int)(((byte)(144)))), ((int)(((byte)(111))))); this.AutomaticUpdateStatusIcon.Image = global::XPSecurityCenter.Properties.Resources._51804_34x34_ico_error_f; this.autoUpatesStatusTxt.Text = "Off"; this.AutomaticUpdatesDescribTxt.Text = "Automatic Update is Off./nAutomatic Updates is turned off./nAutomatic Update helps you keep Windows up-to-date, so turn it On again."; break; case 2: this.automaticUpdatePanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(234)))), ((int)(((byte)(144)))), ((int)(((byte)(111))))); this.AutomaticUpdateStatusIcon.Image = global::XPSecurityCenter.Properties.Resources._51804_34x34_ico_error_f; this.autoUpatesStatusTxt.Text = ""; break; case 3: this.automaticUpdatePanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(234)))), ((int)(((byte)(144)))), ((int)(((byte)(111))))); this.AutomaticUpdateStatusIcon.Image = global::XPSecurityCenter.Properties.Resources._51804_34x34_ico_error_f; this.autoUpatesStatusTxt.Text = ""; break; case 4: this.btnTurnONAU.Visible = false; this.panel10.Visible = false; this.automaticUpdatePanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(220)))), ((int)(((byte)(228)))), ((int)(((byte)(252))))); this.AutomaticUpdateStatusIcon.Image = global::XPSecurityCenter.Properties.Resources._51804_34x34_ico_check_f; this.autoUpatesStatusTxt.Text = "On"; this.AutomaticUpdatesDescribTxt.Text = "Automatic Update is On./nAutomatic Update helps you keep Windows up-to-date."; break; } }

现在,我们必须添加代码,让我们的应用找到防病毒产品的用户的PC 。

#region Monitor Antivirus Program private void MonitorAntivirusProduct_Tick(object sender, EventArgs e) { try { ManagementObjectSearcher search = new ManagementObjectSearcher("SELECT * FROM AntiVirusProduct"); string name = ""; foreach (ManagementObject obj in search.Get()) { name = obj["displayName"].ToString(); } this.virusProtectionDescribTxt.Text = name + " is protecting your system."; this.virusProtectionPanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(220)))), ((int)(((byte)(228)))), ((int)(((byte)(252))))); this.VirusProtectionStatusIcon.Image = global::XPSecurityCenter.Properties.Resources._51804_34x34_ico_check_f; this.virusProtectionStatusTxt.Location = new System.Drawing.Point(453, 7); this.virusProtectionStatusTxt.Text = "On"; } catch { this.virusProtectionPanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(234)))), ((int)(((byte)(144)))), ((int)(((byte)(111))))); this.VirusProtectionStatusIcon.Image = global::XPSecurityCenter.Properties.Resources._51804_34x34_ico_error_f; this.virusProtectionStatusTxt.Location = new System.Drawing.Point(404, 7); this.virusProtectionStatusTxt.Text = "Not found"; this.virusProtectionDescribTxt.Text = "No antivirus program is installed on this PC."; } } #endregion

终于,我们自己的Windows安全中心是建立和运行。

结论

正如您可能会看到, Windows安全中心在Windows ® XP是很容易建立。我们学习什么? -那么,我们学到了更多关于如何安全中心工程;我们还研究了深入研究了Windows安全中心。我们也作了充分的工作我们自己的安全中心的基础上的API和其他功能,也可。因此,您可能会看到,您可以建立任何东西,只是它的研究第一次。祝您好运!所有用户和开发商,我希望这篇文章很有帮助。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值