Use Visual C # To create a personalized IE browser

Source: Internet
Author: User
Internet Explorer is the most widely used browser on the Windows platform, but the Internet Explorer provided by Microsoft is so simple that it has no special features. How can we modify Internet Explorer using programs, what about creating IE with its own characteristics? After thinking, I found the method for modifying ie through the registry. Next I will introduce this method to you.

First, familiarize yourself with the methods and functions for modifying the Registry in C. The Registry class and registrykey class are provided in VC # To perform registry operations. The Registry class encapsulates the seven basic keys of the registry:

Registry. classesroot corresponds to the hkey_classes_root primary key
Registry. currentuser corresponds to the HKEY_CURRENT_USER primary key
Registry. localmachine corresponds to the HKEY_LOCAL_MACHINE primary key
Registry. User corresponds to the hkey_user primary key
Registry. currentconfig corresponds to the primary key of heky_current_config
Registry. dynda corresponds to the hkey_dyn_data primary key
Registry. performancedata corresponds to the hkey_performance_data primary key.

The registrykey class encapsulates basic operations on the registry, including reading, writing, and deleting. The main functions are as follows:

Opensubkey (string name) is used to open a specified subkey.
The getsubkeynames () method is used to obtain the names of all subkeys under the primary key. The returned value is a string array.
The getvaluenames () method is used to obtain all the key names in the current subkey, and its return value is also a string array.
The getvalue (string name) method specifies the key value of a key.

The written functions include:

The createsubkey (string name) method adds a subkey.
Setvalue (string name, string value) is used to set the key value of a key.
Deleted functions:

Deletesubkey () method: deletes a specified subkey.
Deletesubkeytree () method:

This method completely deletes the specified sub-Key Directory, that is, deleting the sub-key and all sub-keys below the sub-key.

You can modify ie through the registry. Here I will briefly introduce several common methods to modify IE.

If you want to enable or disable the dynamic effect of the IE window, you can open the hkey _ CURRENT_USER/control panel/desktop/windowmetrics key, create the string values "minanimat" and "maxanimat" in the window on the right, and set the value to "0" and "1 ", in this way, the IE window is incrementally changed during the minimal switchover.

If we change to the IE Toolbar to add a background, expand the HKEY_CURRENT_USER \ Software \ Microsoft \ Internet Explorer \ toolbar key value, and create a new string value named "backbitmap" under the explorer primary key, modify the value to the complete path and file name of the prepared BMP image. This completes the purpose of adding a background image to the IE Toolbar.
The method implemented by C # programming is as follows:

1. Dynamic Effect of IE window

//-------------------------------------
// Changeie. CS? 2004 by yudehui
//-------------------------------------
Using system;
Using Microsoft. Win32; // You must reference this namespace for registry operations.
Namespace changeie
{
Class changeie
{
[Stathread]
Static void main (string [] ARGs)
{
Registrykey pregkey;
Pregkey = registry. currentuser. opensubkey ("Control Panel // desktop // windowmetrics", true );
If (pregkey = NULL)
{
Console. writeline ("key value does not exist ");
}
Else
{
Pregkey. setvalue ("minanimate", "1 ");
Pregkey. setvalue ("maxanimate", "1 ");
Console. writeline ("modified successfully ");

}
Pregkey. close;
}
}
}


2. Change the background of the IE Toolbar


//-------------------------------------
// Changeie. CS? 2004 by yudehui
//-------------------------------------
Using system;
Using Microsoft. Win32; // You must reference this namespace for registry operations.
Namespace changeiebackcolor
{
Class changeiebackcolor
{
[Stathread]
Static void main (string [] ARGs)
{
Registrykey pregkey;
Pregkey = registry. currentuser. opensubkey ("software // Microsoft // Internet" +
"Explorer // toolbar // Explorer", true );
If (pregkey = NULL)
{
Console. writeline ("key value does not exist ");
}
Else
{
Pregkey. setvalue ("backbitmap", "C: // windows // greenstone.bmp ");
Console. writeline ("modified successfully ");

}
Pregkey. close;
}
}
}


The above two simple examples are just a simple setup of IE. I believe you have some knowledge of registry operations under C. If you are interested, you can make more personalized changes to IE. The above code is successfully debugged under Windows2003 + vs. net2003.

Note: It is dangerous to operate the Registry. Back up the registry before performing the operation to prevent system crashes due to misoperations.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.