Monitoring Changes in IE Settings

Introduction

Internet users often can change their IE settings (from Tools ->Internet Options). For example, the font settings can be changed to bold. If an application embeds IE, it might be interested in knowing when the font setting has changed, so it can use the new font. This article discusses a method to know when exactly an IE setting has changed. A sample application is provided that monitors changes in IE's multimedia and zone related settings.

WM_SETTINGCHANGE

When a user changes IE settings, IE sends WM_SETTINGCHANGE to all top-level windows. In order for an application to take advantage of this, it should handle this message. The message merely signifies that a setting has changed. It is up to the application to look at relevant places (Registry, zone manager, and so forth) to know exactly what setting has changed. Here, I have described ways to monitor the following settings in IE. The steps to access the property from menu are shown in Column 2.

Property Steps Taken
Play Sound Internet Options -> Advanced
Play Video Internet Options -> Advanced
Show Pictures Internet Options -> Advanced
Active Scripting Internet Options -> Security -> Internet Zone -> Scripting
Scripting of Java Applets Internet Options -> Security -> Internet Zone -> Scripting

The sample code provided also deals with these settings. The application, on startup, collects their values. Upon receiving WM_SETTINGCHANGE, the application again collects the values and compares whether any setting relevant for it has changed. If such a change has happened, the application throws up a message box with the relevant setting name that has changed.

Advanced Settings

Play Sound, Play Video, and Show Pictures can be configured as Enable, Disable, or Prompt from the Advanced tab. IE maintains their settings in the Registry under HKCU\Software\Microsoft\Internet Explorer\Main. Applications should look for any change under this path in the Registry to know whether these multimedia settings have changed. The subkeys they use in the Registry are provided below.

Property Registry Subkey
Play Sound Play_Background_Sounds
Play Video Display Inline Videos
Show Pictures Display Inline Images

The data type used for these subkeys is string. A "yes" indicates the property has been enabled. A "no" indicates the property is disabled.

Script Settings

Users can set the script setting for each of the zones available on the Tools -> Internet Options -> Security tab. The description of zones is beyond the scope of this document. Description on zones can be found at http://www.nwnetworks.com/iezones.htm and http://msdn.microsoft.com/workshop/security/szone/overview/overview.asp. This part of the document discusses monitoring script settings in Internet Zone.

The Active Scripting and Scripting properties of Java Applets can be set to have the following Action Policies associated with them.

Action Policy Description
URLPOLICY_ALLOW Always allows scripts to be downloaded
URLPOLICY_DISALLOW Always blocks scripts from being downloaded
URLPOLICY_QUERY Prompts the user to know whether the script can be allowed to be downloaded

Internet Zone Manager

Internet Zone Manager is an object that manages zones. Windows comes with a default URL Zone Manager (available in urlmon.dll). The Zone Manager implements the IInternetZoneManager Interface. An application can use this COM object to know about the Action Policy for the script settings. The GetZoneActionPolicy function can be used to know about the action policy set for URLs in any zone. The usage is as follows.

/* Create the object */
hr = CoCreateInstance(CLSID_InternetZoneManager, NULL,
                      CLSCTX_INPROC_SERVER,
                      IID_IInternetZoneManager,
                      (void**)&pZoneMgr);

/* Get the Action Policy for Scripts */

DWORD bytePolicy;
size_t iSize = sizeof(bytePolicy);
hr = pZoneMgr->GetZoneActionPolicy( URLZONE_INTERNET,
                                    URLACTION_SCRIPT_RUN,
                                    (BYTE*)&bytePolicy,
                                    iSize,
                                    URLZONEREG_HKCU);

At startup, the application gets the Action Policy and, upon receiving WM_SETTINGCHANGE, again uses the Zone Manager to know whether the script setting in the zone has changed.

Internet Security Manager

Applications, such as a BHO or one that embeds IE, might need to dynamically determine the zone of the URL visited. Such applications need not monitor for WM_SETTINGCHANGE because they need to know the zone of a URL and action associated with it only when the request for navigation comes in. They can make use of another default COM object, CLSID_InternetSecurityManager, to know the zone under which the URL comes. The usage is as follows.

/*Create Zone Manager */

hr = CoCreateInstance( CLSID_InternetZoneManager,
                       NULL,
                       CLSCTX_INPROC_SERVER,
                       IID_IInternetZoneManager,
                       (void**)&pZoneMgr);

/* Create Security Manager */

hr = CoCreateInstance(CLSID_InternetSecurityManager,
                      NULL,
                      CLSCTX_INPROC_SERVER,
                      IID_IInternetSecurityManager,
                      (void**)&pSecurityMgr);

/*Know the Zone */
pSecurityMgr->MapUrlToZone( szUrl, &dwZone, 0 );

/* Know the Action Policy */
DWORD bytePolicy;
size_t iSize = sizeof(bytePolicy);
hr           = pZoneMgr->GetZoneActionPolicy( dwZone,
                                              URLACTION_SCRIPT_RUN,
                                              (BYTE*)&bytePolicy,
                                              iSize ,
                                              URLZONEREG_HKCU);


About the Author

Venkatesan Krishnasamy

I live in Hyderabad, India. I work in an ISP operating in the US. I enjoy coding in C++ and have been working in it for the past 4 years.

Downloads

Comments

  • Power_Forward

    Posted by Kawhi_Leonard on 05/19/2014 02:16pm

    Awesome! Just what I was looking for. I needed to detect dynamically whether "Active Scripting" is enabled in IE. Looks like this will do. Thanks a lot.

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: December 11, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT Market pressures to move more quickly and develop innovative applications are forcing organizations to rethink how they develop and release applications. The combination of public clouds and physical back-end infrastructures are a means to get applications out faster. However, these hybrid solutions complicate DevOps adoption, with application delivery pipelines that span across complex hybrid cloud and non-cloud environments. Check out this …

  • CentreCorp is a fully integrated and diversified property management and real estate service company, specializing in the "shopping center" segment, and is one of the premier retail service providers in North America. Company executives travel a great deal, carrying a number of traveling laptops with critical current business data, and no easy way to back up to the network outside the office. Read this case study to learn how CentreCorp implemented a suite of business continuity services that included …

Most Popular Programming Stories

More for Developers

RSS Feeds