Getting Started Using the ICS and ICF API
[Internet Connection Firewall may be altered or unavailable in subsequent versions. Instead, use the Windows Firewall API.]
To use ICS, the software application must first obtain an INetSharingManager interface. Use the CoCreateInstance function to obtain this interface. The CoCreateInstance function requires a class identifier (CLSID). One way to obtain the CLSID is to call the CLSIDFromProgID function with the programmatic ID for the home networking object: HNetCfg.HNetShare.1.
The INetSharingManager interface provides access directly or indirectly to all the other COM interfaces in the ICS API.
Enumerating RAS Connections Requires CoInitializeSecurity
To enumerate Remote Access Service (RAS) connections, each process calling the ICS API should call the CoInitializeSecurity function. The following line of code shows the appropriate parameter values to use when making this call.
CoInitializeSecurity (NULL, -1, NULL, NULL,
RPC_C_AUTHN_LEVEL_PKT,
RPC_C_IMP_LEVEL_IMPERSONATE,
NULL, EOAC_NONE, NULL);
The call to CoInitializeSecurity should be made right after calling CoInitialize( NULL ).