SOL9 Sample: WindowsFirewall

SOL9 2.0 Samples

1 Screenshot


2 Source code

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


#include <sol\net\WindowsFirewall.h>


void _tmain(int argc, TCHAR* argv[])
{
  try {
    WindowsFirewall firewall;

    BOOL rc;
    HRESULT hr =S_OK;
    hr = firewall.isFirewallEnabled(rc);
    if (SUCCEEDED(hr) && rc) {
      printf("OK. isFirewallEnabled: Firewall is enabled\n");
    } else {
      printf("NG. isFirewallEnabled: Firewall is diabled\n");
    }

    hr = firewall.isExceptionNotAllowed(rc);
    if (SUCCEEDED(hr) &&rc) {
      printf("OK. isExceptionNotAllowed: Exception is not allowed\n");
    } else {
      printf("NG. isExceptionNotAllowed: Exception is allowed\n");
    }

    int port = 80;

    hr = firewall.setPortEnabled(port, true, true);
    if (SUCCEEDED(hr)) {
      printf("OK. setPortEnabled: port=%d is enabled\n", port);
    } else {
      printf("NG. setPortEnabled: port=%d is not enabled\n", port);
    }

    hr = firewall.isPortEnabled(port, true, rc);
    if (SUCCEEDED(hr) &&rc) {
      printf("OK. isPortEnabled: port=%d is enabled\n", port);
    } else {
      printf("NG. isPortEnabled: port=%d is not enabled\n", port);
    }
      
      
  } catch (HRESULT hr) {
    printf("Exception %0x\n", hr);
  }

}

Last modified: 2 May 2016

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