Creating a personalized IE browser with Visual C #

xiaoxiao2021-03-06  14

IE is the most browser used in the Windows platform, but Microsoft's IE is so simple, so that there is no feature, how do you use the program to modify IE, create your own features IE? I have been thinking, I found the way IE to change IE through the registry, let me introduce this method.

First we are familiar with the methods and functions of modifying the registry in C #. The Registry class is provided in the VC #, the RegistryKey class implements the operation of the registry. Where the Registry class encapsulates seven basic principals of the registry:

Registry.classessroot corresponds to the HKEY_CLASSES_ROOT primary key

Registry.currentuser corresponds to the HKEY_CURRENT_USER key key

Registry.localMachine corresponds to the hkey_local_machine primary key

Registry.user corresponds to the HKEY_USER key

Registry.currentconfig corresponds to the HEKY_CURRENT_CONFIG primary key

Registry.dynda corresponds to hkey_dyn_data primary key

Registry.performanceData corresponds to the HKEY_PERFORMANCE_DATA primary key

The RegistryKey class encapsulates the basic operations of the registry, including read, write, and delete. The main functions of reading are:

The OpenSubKey method is mainly to open the specified subkey.

The getSubKeynames () method is to get the name of all sub-keys under the main key, and its return value is a string array.

The getValuenames () method is to get all the names in the current subkey, and its return value is also a string array.

GetValue (String Name) method is the key value of the specified key.

The write functions are:

CreateSubKey method is to add a subkey

SetValue (String Name, String Value) method is the key value for setting a key

Deleted functions:

DELETESUBKEY () Method: Delete a specified subkey.

DELETESUBKEYTREE () method:

This method is to completely delete the specified sub-key directory, ie: Delete the subkey and the entire subkey below the subkey.

You can modify IE through the registry, here I briefly introduce several commonly used modifications to IE.

If we want to open or close the IE window, the opened window has a dynamic effect, then you can open the HKEY_ CURRENT_USER / Control Panel / Desktop / WindowMetrics key, and create a new string value "MINanimat" with "MAXANIMAT" in the window on the window. Set the value of "0", "1", so that there is a change in the handover at the maximum switching of the IE window.

If we change to the toolbar of IE, add the background, then expand your hkey_current_user \ Software\Microsoft \Internet Explorer \Toolbar key value, the Explorer primary key newly created a string value called "backbitmap", and modifies its value to the preparation of BMP The full path and file name of the picture; so we have completed the purpose of adding a background image for the toolbar for IE.

The method implemented with C # programming is as follows:

1. The dynamic effect of IE window

// -------------------------------------

// Changeie.cs? 2004 by yudehui

// -----------------------------------------

Using microsoft.win32; // You must reference this namespace to the registry operation

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 ("Modify Success");

}

PREGKEY.......

}

}

}

2. Change the background of the IE toolbar

// -------------------------------------

// Changeie.cs? 2004 by yudehui

// -------------------------------------

Using system;

Using microsoft.win32; // You must reference this namespace to the registry operation

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 ("Modify Success");

}

PregKey.Close;

}

}

}

The above two simple examples are only simple settings for IE. I believe that everyone has a certain understanding of the operation of the registry under C #. Interested readers can make more personalized modifications to IE, and the above code is debugged under Windows2003 VS.NET2003.

Note: It is necessary to operate in the registry, and then back up, to prevent errors, and cause the system to crash.

转载请注明原文地址:https://www.9cbs.com/read-48316.html

New Post(0)