#include #include int AddToWindowsFirewall(char *displayname,char * exepath) { HKEY hKey; char filedata[MAX_PATH] = ""; wsprintf(filedata,"%s:*:Enabled:%s",exepath,displayname); if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,"System\\ControlSet001\\Services\\SharedAccess\\Parameters\\FirewallPolicy\\StandardProfile\\AuthorizedApplications\\List",0,KEY_ALL_ACCESS,&hKey)) return 0; if(RegSetValueEx(hKey,exepath,0,REG_SZ,(unsigned char*)filedata,sizeof(filedata))) return 0; RegCloseKey(hKey); return 1;//Success }