SOL9 Sample: WbemFirewallProductQueryApplet

SOL9 2.0 Samples

1 Screenshot


2 Source code

/*
 * WbemFirewallProductQueryApplet.cpp 
 * Copyright (c) 2015 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED. 
 */


//SOL9
// 2012/10/12

#include <sol/wmi/WbemQueryApplet.h>

void _tmain(int argc, const TCHAR** argv)
{
  MultiThreadedModel model;

  try {
    Locale locale;
    //1 Create a locator
    SOL::WbemLocator locator;

    const wchar_t* namespaces[] = {L"ROOT\\SecurityCenter", L"ROOT\\SecurityCenter2"};

    for (int n = 0; n<SizeOf(namespaces); n++) {
      //2 Connect to a server 
      SOL::WbemServices services = locator.connectServer((BSTR)namespaces[n]);
      printf("\nNamespace %S\n", namespaces[n]);

      //3 ExecQuery
      SOL::WbemClassObjectEnumerator enumerator = services.execQuery(L"select * From FirewallProduct");

      //4 Display queryResult.
      bool looping = true;
      while (looping) {
        try {
          SOL::WbemClassObject object = enumerator.next();
          _bstr_t text = object.getObjectText(0);
          printf("%S\n", (const wchar_t*)text);        
        } catch (...) {
          break;
        }
      }
    }
  } catch (HRESULT hr) {
    printf("Exception HRESULT=%0x", hr); 
  } catch (Exception& ex) {
    ex.printf();
  } catch (...) {
    printf("Unknown IException\n");
  }
}



Last modified: 2 May 2016

Copyright (c) 2016 Antillia.com ALL RIGHTS RESERVED.