Windows安全中心API

发布于 2024-12-09 14:48:04 字数 165 浏览 1 评论 0原文

我想访问 Windows 安全中心来检查多个安全功能的状态。

示例:

  • 防火墙状态
  • Windows 是否是最新的
  • 计算机是否有病毒防护

我怎样才能做到这一点?

2003、XP、Vista、7

I would like to access the Windows Security Center to check the status of several security features.

Examples:

  • Firewall status
  • Whether Windows is up to date
  • Whether the computer has virus protection

How am I able to do this?

2003, XP, vista, 7

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

伏妖词 2024-12-16 14:48:04

在 Vista+ 上,您可以通过 获取其状态摘要WscGetSecurityProviderHealth

On Vista+ you can get a summary of its status via WscGetSecurityProviderHealth.

一个人的旅程 2024-12-16 14:48:04
#include <Windows.h>
#include <string>
#include <iostream>
#include <Wscapi.h>
#pragma comment(lib, "Wscapi.lib")
using namespace std;

string printStatus(WSC_SECURITY_PROVIDER_HEALTH status)
{
  switch (status)
  {
  case WSC_SECURITY_PROVIDER_HEALTH_GOOD: return "GOOD";
  case WSC_SECURITY_PROVIDER_HEALTH_NOTMONITORED: return "NOTMONITORED";
  case WSC_SECURITY_PROVIDER_HEALTH_POOR: return "POOR";
  case WSC_SECURITY_PROVIDER_HEALTH_SNOOZE: return "SNOOZE";
  default: return "Status Error";
  }
}

void getHealth()
{
  WSC_SECURITY_PROVIDER_HEALTH health;
  if (S_OK == WscGetSecurityProviderHealth(WSC_SECURITY_PROVIDER_FIREWALL, &health))
    cout << "FIREWALL:          " << printStatus(health) << endl;
  if (S_OK == WscGetSecurityProviderHealth(WSC_SECURITY_PROVIDER_AUTOUPDATE_SETTINGS, &health))
    cout << "AUTOUPDATE:        " << printStatus(health) << endl;
  if (S_OK == WscGetSecurityProviderHealth(WSC_SECURITY_PROVIDER_ANTIVIRUS, &health))
    cout << "ANTIVIRUS:         " << printStatus(health) << endl;
  if (S_OK == WscGetSecurityProviderHealth(WSC_SECURITY_PROVIDER_ANTISPYWARE, &health))
    cout << "ANTISPYWARE:       " << printStatus(health) << endl;
  if (S_OK == WscGetSecurityProviderHealth(WSC_SECURITY_PROVIDER_INTERNET_SETTINGS, &health))
    cout << "INTERNET SETTINGS: " << printStatus(health) << endl;
  if (S_OK == WscGetSecurityProviderHealth(WSC_SECURITY_PROVIDER_USER_ACCOUNT_CONTROL, &health))
    cout << "UAC:               " << printStatus(health) << endl;
  if (S_OK == WscGetSecurityProviderHealth(WSC_SECURITY_PROVIDER_SERVICE, &health))
    cout << "SERVICE:           " << printStatus(health) << endl;
  if (S_OK == WscGetSecurityProviderHealth(WSC_SECURITY_PROVIDER_ALL, &health))
    cout << "ALL:               " << printStatus(health) << endl;

}

void main()
{
  getHealth();
}
#include <Windows.h>
#include <string>
#include <iostream>
#include <Wscapi.h>
#pragma comment(lib, "Wscapi.lib")
using namespace std;

string printStatus(WSC_SECURITY_PROVIDER_HEALTH status)
{
  switch (status)
  {
  case WSC_SECURITY_PROVIDER_HEALTH_GOOD: return "GOOD";
  case WSC_SECURITY_PROVIDER_HEALTH_NOTMONITORED: return "NOTMONITORED";
  case WSC_SECURITY_PROVIDER_HEALTH_POOR: return "POOR";
  case WSC_SECURITY_PROVIDER_HEALTH_SNOOZE: return "SNOOZE";
  default: return "Status Error";
  }
}

void getHealth()
{
  WSC_SECURITY_PROVIDER_HEALTH health;
  if (S_OK == WscGetSecurityProviderHealth(WSC_SECURITY_PROVIDER_FIREWALL, &health))
    cout << "FIREWALL:          " << printStatus(health) << endl;
  if (S_OK == WscGetSecurityProviderHealth(WSC_SECURITY_PROVIDER_AUTOUPDATE_SETTINGS, &health))
    cout << "AUTOUPDATE:        " << printStatus(health) << endl;
  if (S_OK == WscGetSecurityProviderHealth(WSC_SECURITY_PROVIDER_ANTIVIRUS, &health))
    cout << "ANTIVIRUS:         " << printStatus(health) << endl;
  if (S_OK == WscGetSecurityProviderHealth(WSC_SECURITY_PROVIDER_ANTISPYWARE, &health))
    cout << "ANTISPYWARE:       " << printStatus(health) << endl;
  if (S_OK == WscGetSecurityProviderHealth(WSC_SECURITY_PROVIDER_INTERNET_SETTINGS, &health))
    cout << "INTERNET SETTINGS: " << printStatus(health) << endl;
  if (S_OK == WscGetSecurityProviderHealth(WSC_SECURITY_PROVIDER_USER_ACCOUNT_CONTROL, &health))
    cout << "UAC:               " << printStatus(health) << endl;
  if (S_OK == WscGetSecurityProviderHealth(WSC_SECURITY_PROVIDER_SERVICE, &health))
    cout << "SERVICE:           " << printStatus(health) << endl;
  if (S_OK == WscGetSecurityProviderHealth(WSC_SECURITY_PROVIDER_ALL, &health))
    cout << "ALL:               " << printStatus(health) << endl;

}

void main()
{
  getHealth();
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文