File Association and application-Overview of registry usage II

Source: Internet
Author: User


File Association and application of the Registry-Overview of registry usage II
You may know that when you select a file (folder or System icon) and right-click it, a menu will pop up, you can choose all the "functions" (or "operations") on the menu, but have you noticed whether your right-click menu is expanded after you install some application software, take WinZip as an example. After WinZip is installed, the options "add to zip" and "add to xxx.zip" and "add to xxx.zip" are added to the context menu of the file or folder, we can't help but ask how these options are added. You can add them by yourself. With these problems, let's look at the file association in windows.
Figure 1
What is File Association? In other words, it is the function items displayed on the right-click menu when selecting different types of files. Each function item corresponds to an association. When a function (operation) is selected, the system executes the corresponding processing. Program . As for what file operations correspond to what kind of handler, it is recorded in the system registry. Therefore, to really find out the file association, you must thoroughly study the registry. After this problem is solved, we can use the registry to create, modify, and delete associations for files as needed.
Since the associated information is written in the registry, how does it constitute it in the registry? Open the registry and observe the primary keys under the root key hkey_classes_root. (This may be easier to describe) Do you see a lot of vertices (.) above, followed by a primary key of the file extension, as shown in Figure 2
Figure 2
For example, .bat,.txt,.lnk,.bmp. We call this type of primary keys as "extension primary keys". Each extension primary key has a default key value. For example, the default value of primary key. bat is batfile; the default value of. lnk primary key is lnkfile. Let's take these two examples to see whether you see the rule. That is, if the "primary key extension" is named. XXX (XXX is the extension of a certain type of files), the default key value is xxxfile. Of course, not all default values are like this, or multiple primary keys may correspond to the same default value. For example, for the master key. keystore and master key. jpg, the default values of jpgfile).html and htm are both htmlfile. Why are the default values of the primary keys of so many extensions? I am sorry for the reason. The default key value is very small. It is a bridge and link between files. It associates the file type (identified by the extension) with the file type. If you don't believe it, you can change the default key value of a "primary key with an extension" to a mess, and you will find that many associated items of this type of files disappear from the context menu. Since this important default key value acts as a bridge, how is the file association defined at the other end of the bridge? Let's continue to look at the Registry and let it explain to us. It is still under the root key of hkey_classes_root. We can see that the root key has the following primary keys. For example, batfile, txtfile, and lnkfile. (3)
Figure 3
These primary keys seem to be the default values of the "extension primary key" We just mentioned. Yes, the above default value is changed to the primary key name here-this is the bridge. We call this type of primary keys as "id Primary keys ". Generally, there are several important primary keys under the "primary key ID": (4)
Thu
Defaulticon primary key. Its function is to define the default icon of this type of files.
Shell primary key, which is the "root" of File Association in the center of this article. All the associations of files are parasitic under this "root", which defines the association of such files with multiple programs. Its default value is also very useful. Do you still remember to double-click a file to open the file (for registered files), which is the default open method set by the system registry, it is controlled by the default key value of the shell primary key. Each primary key under it can be called "correlated primary key" (4 ). The key name of the "correlated primary key" is arbitrary (it is recommended to use English), and its default key value is also of interest to us. Because this default key value is directly displayed in the right-click menu, and each "associated primary key" has a command primary key, this primary key defines the corresponding execution program of the association ". As shown in figure 5, the Association to this file has been revealed.
Figure 5
The following uses the. reg file (the script file of the registry) as an example to describe the association process.
First, the. reg file has an "extension primary key" under the hkey_classes_root Root Key ".. The default value of Reg is regfile, indicating that the primary key associated with Reg files is regfile. Next, find "identify primary key" regfile under the root key, and there is a dfaulticon primary key under the regfile primary key to define the default icon of the reg file. The default key is the full path File Name of the icon. For example, c: \ windows \ regedit.exe,1(the 2nd icons in regedit.exe ). Under the primary key of regfile, there is also a primary key shell called the "root" above. The Association of the reg file is recorded in shell. Next we will create an association for regt. Step: Under the shell primary key, create the primary key xxf (with any name), set its default value to "Xu Xifeng's text editor", and then create a primary key command under the primary key xxf, set the default value to c: \ windows \ notepad.exe % 1. The default value is to use NotePad to open the current reg file. If the "% 1" parameter is not specified, only the Notepad program is run and the current file is not opened. After completing the settings, you can check the "right-click menu" of the reg file. Is there an additional option (6) for "Xu Xifeng's text editor !~

Figure 6
The above only applies to the Association of common files. However, in windows, apart from files, folders and special documents (such as my computer, drive, recycle bin, etc ). So how can we set the association? Remember that there are several important system-associated primary keys under the hkey_classes_root root key:
*: Act on all files. It is the same as the association method of "identify primary key.
Directory: Act on general folders.
Folder: acts on all folders, including special files, such as control panel and recycle bin.
Drive: acts on the drive, such as drive a, drive B, and drive C.
Unknow: applies to file types that are not recognized by the system, that is, file types that are not registered.
The most basic file association is mentioned here. Let's take a look at the file association application.
One of the applications: Making MS-DOS everywhere.
Often used dos friends may be somewhat bored, because every time you enter the DOS mode, you must select "Start \ Program \ MS-DOS mode ". With file associations, we can add the MS-DOS Method to the right-click menu of any file, which saves a lot of trouble:
Expand the registry to the hkey_classes_root \ * \ shell branch. (Add MS-DOS mode in the context menu of all files) create a primary key MS-DOS, set its default value to enter MS-DOS mode, and create a command primary key under the primary key of the MS-DOS, set the default value to "C: \ WINDOWS \ command.com ".
Expand the registry to the hkey_classes_root \ Folder \ shell Branch (add the MS-DOS mode in the right-click menu in all folders) as above.
Application 2: Hide the small arrow in the shortcut icon.
If you think the small arrow in the shortcut icon is a little blind, you can remove it by using association, expand the registry to the hkey_classes_root \ lnkfile branch, and delete the key value isshortcut under the primary key of lnkfile, expand the registry to the hkey_classes_root \ piffile branch, and delete the key value isshortcut under the primary key of the piffile.
Application 3: use NotePad to edit the BAT file.
Sometimes I want to edit the BAT file, and habitually double-click it. This double-click does not open and edit it, But executes it, which is annoying. You can change the file association in the registry. Expand the registry to the hkey_classes_root \ batfile \ shell branch, and change the default value of the shell primary key from open to edit.
APP 4: Change the default icon of a type of files.
Take the TXT file as an example. Change the icon of the TXT file to "my computer. Expand the registry to the hkey_classes_root \ txtfile \ defaulticon branch, and change the default key value of the primary key defauticon to "C: \ WINDOWS \ assumer.exe, 0.
Application 5: add an "open mode" for all files ".
Expand the registry to the hkey_classes_root \ * \ shell branch, create the primary key open_as, set its default value to "select Open Mode", create a primary key command under the primary key open_as, and set its default value: "C: Windows \ rundll32.exe shell32.dll, openas_rundll % 1"
APP 6: Add "Shut Down" to the right-click menu.
Expand the registry to the heky_classes_root \ directory \ shell branch, create a primary key close, set its default value to "Close the system", and then create a primary key command under the close primary key, set its default value: "C: \ WINDOWS \ rundll32.exe user.exe, exitwindows"
In the above six applications, the basic structure and framework of file association can be summarized in general, and the structure and framework of file association can be clarified. Adding association by yourself is just a piece of cake. If you are interested, you can fill up your right-click menu. If you want to learn more about file associations at a deeper level, please refer to books and materials on the Windows registry or contact me, my email is amen.twty@china.net. In Article Before the conclusion, let us know a little trick: After the Registry has been modified, it needs to be restarted in many cases to take effect. Here I will tell you a way to quickly change the Registry without restarting: Select "Start \ close system". After the "close system" box appears, press CTRL + ALT + DEL to display the "End Task" box. Select "Explorer" and click "End Task". Wait for a while (about 10 seconds ), the "End Task" confirmation box appears. Click "End Task. (Source: viphot)

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.