使用注册表关闭Windows防火墙

#include "stdafx.h"
#include <windows.h>

int _tmain(int argc, _TCHAR* argv[])
{

    HKEY hKey = nullptr;
    LONG lRet = NULL;
    char* szSubkey = "SYSTEM\\CurrentControlSet\\services\\SharedAccess\\Parameters\\FirewallPolicy\\StandardProfile";
    if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, szSubkey, 0, KEY_WRITE, &hKey)) return 0;

    printf("Open hKey Success\n");

    DWORD lpData = 0x00000000;
    if (RegSetValueExA(hKey, "EnableFirewall", 0, REG_DWORD, (byte*)&lpData, sizeof(DWORD)))return false;

    printf("Disable Firewall Success!\n");

    system("pause");

    return 0;
}

猜你喜欢

转载自blog.csdn.net/cssxn/article/details/80653178