The following example instantiates the default security manager to determine the correct zone for the input URL, szUrl.
const char *rgZoneNames[] = { "Local", "Intranet", "Trusted", "Internet", "Restricted" };
IInternetSecurityManager* pInetSecMgr;
HRESULT hr = CoCreateInstance(CLSID_InternetSecurityManager, NULL, CLSCTX_ALL,
IID_IInternetSecurityManager, (void **)&pInetSecMgr);
if (SUCCEEDED(hr))
{
DWORD dwZone;
hr = spInetSecMgr->MapUrlToZone(szUrl, &dwZone, 0);
if (hr == S_OK)
{
if (dwZone < 5)
printf("ZONE: %s (%d)\n", rgZoneNames[dwZone], dwZone);
else
printf("ZONE: Unknown (%d)\n", dwZone);
}
else
printf("ZONE: Error %08x\n", hr);
pInetSecMgr->Release();
}