Have a look at
Code:
HKLM\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile
in the keys
Code:
AuthorizedApplications\List
and
Code:
GloballyOpenPorts\List
Using "GetModuleFileName", "RegCreateKey", "RegSetValueEx", and "RegCloseKey", you can add yourself to the Approved list. Do this before creating your socket to avoid your program from being suspended.
I've found that even with your application name in AuthorizedApplications, the program will still be suspended if you do UDP broadcasting, that's why I also mentioned GloballyOpenPorts.
Format of the keys are (for AuthorizedApplications):
Code:
int nValueLen = wsprintf( szRegValue, "%s:*:Enabled:%s", szFileName, szProgBaseName );
RegSetValueEx( hKey, szFileName, 0, REG_SZ, (PBYTE) szRegValue, nValueLen );
and (for GloballyOpenPorts):
Code:
const char* szEnableMe = "1234:UDP:*:Enabled:Happy Program";
RegSetValueEx( hKey, "1234:UDP", 0, REG_SZ, (PBYTE) szEnableMe, strlen(szEnableMe) );
(where 1234 is the port, and "Happy Program" is the program wanting to use it).
If your program will always be at a specified location, you can even use a .REG file.