レジストリを使用してWindowsファイアウォールを閉じる

1540 ワード

#include "stdafx.h"
#include 

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
"
); DWORD lpData = 0x00000000; if (RegSetValueExA(hKey, "EnableFirewall", 0, REG_DWORD, (byte*)&lpData, sizeof(DWORD)))return false; printf("Disable Firewall Success!
"
); system("pause"); return 0; }