sam
sam

Reputation: 1401

Windows security Center API

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

Examples:

How am I able to do this?

2003, XP, vista, 7

Upvotes: 4

Views: 2287

Answers (2)

Praveen Patel
Praveen Patel

Reputation: 519

#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();
}

Upvotes: 0

Alex K.
Alex K.

Reputation: 175766

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

Upvotes: 4

Related Questions