使用登錄檔關閉Windows防火牆
阿新 • • 發佈:2018-11-08
#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;
}