Created
July 23, 2012 05:40
-
-
Save sandrinodimattia/3162092 to your computer and use it in GitHub Desktop.
Windows Firewall (C++)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HRESULT hr = S_OK; | |
INetFwMgr* fwMgr = NULL; | |
INetFwPolicy* fwPolicy = NULL; | |
_ASSERT(fwProfile != NULL); | |
*fwProfile = NULL; | |
// Create an instance of the firewall settings manager. | |
hr = CoCreateInstance( | |
__uuidof(NetFwMgr), | |
NULL, | |
CLSCTX_INPROC_SERVER, | |
__uuidof(INetFwMgr), | |
(void**)&fwMgr | |
); | |
if (FAILED(hr)) | |
{ | |
printf("CoCreateInstance failed: 0x%08lx\n", hr); | |
goto error; | |
} | |
// Retrieve the local firewall policy. | |
hr = fwMgr->get_LocalPolicy(&fwPolicy); | |
if (FAILED(hr)) | |
{ | |
printf("get_LocalPolicy failed: 0x%08lx\n", hr); | |
goto error; | |
} | |
// Retrieve the firewall profile currently in effect. | |
hr = fwPolicy->get_CurrentProfile(fwProfile); | |
if (FAILED(hr)) | |
{ | |
printf("get_CurrentProfile failed: 0x%08lx\n", hr); | |
goto error; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment