Compartilhar via


CoInternetSetFeatureEnabled function

Enables or disables a specified feature control.

Syntax

HRESULT CoInternetSetFeatureEnabled(
       INTERNETFEATURELIST FeatureEntry,
  _In_ DWORD               dwFlags,
       BOOL                fEnable
);

Parameters

FeatureEntry

A value from the INTERNETFEATURELIST enumeration that indicates the feature control to enable or disable.

dwFlags [in]

Specifies where to set the feature control value. Can be one of the following values:

SET_FEATURE_ON_THREAD (0x00000001)

The current thread.

SET_FEATURE_ON_PROCESS (0x00000002)

The current process.

SET_FEATURE_IN_REGISTRY (0x00000004)

Reserved. Do not use.

SET_FEATURE_ON_THREAD_LOCALMACHINE (0x00000008)

The local machine zone.

SET_FEATURE_ON_THREAD_INTRANET (0x00000010)

The intranet zone.

SET_FEATURE_ON_THREAD_TRUSTED (0x00000020)

The trusted zone.

SET_FEATURE_ON_THREAD_INTERNET (0x00000040)

The Internet zone.

SET_FEATURE_ON_THREAD_RESTRICTED (0x00000080)

The restricted zone.

fEnable

A BOOL that indicates that the feature control specified by FeatureEntry is enabled when fEnable is TRUE.

Return value

Returns one of the following values.

Return code Description
S_OK

Success.

E_FAIL

FeatureEntry is invalid.

 

Remarks

The SET_FEATURE_ON_PROCESS flag is available for all values of INTERNETFEATURELIST except FEATURE_LOCALMACHINE_LOCKDOWN. All other values of dwFlags are available only when FeatureEntry is FEATURE_LOCALMACHINE_LOCKDOWN or FEATURE_PROTOCOL_LOCKDOWN.

Note  You cannot enable FEATURE_LOCALMACHINE_LOCKDOWN with this method, because doing so would bypass initialization that is based on whether this feature is enabled when a process starts. To correctly enable FEATURE_LOCALMACHINE_LOCKDOWN, you must set a Feature Control Key in the registry. For more information, see Introduction to Feature Controls.

 

The CoInternetSetFeatureEnabled function was introduced in Microsoft Internet Explorer 6 for Windows XP Service Pack 2 (SP2).

Examples

This code snippet enables pop-up management behavior for the process. The code is placed inside an application that uses the WebBrowser Control before the navigation command.

    LRESULT lr = 0;
    INTERNETFEATURELIST featureToEnable = FEATURE_WEBOC_POPUPMANAGEMENT;
    
    if (SUCCEEDED(CoInternetSetFeatureEnabled(featureToEnable, SET_FEATURE_ON_PROCESS, true)))
    {
        //Check to make sure that the API worked as expected
        if (FAILED(CoInternetIsFeatureEnabled(featureToEnable,SET_FEATURE_ON_PROCESS)))
        {
            lr = 2;
        }
    }
    else
    {
        //The API returned an error while enabling pop-up management
        lr = 1;
    }

Requirements

Minimum supported client

Windows XP with SP2

Minimum supported server

Windows Server 2003

Product

Internet Explorer 6.0

Header

Urlmon.h

Library

Urlmon.lib

DLL

Urlmon.dll