File association and application-registration form Use the two _ registry

Source: Internet
Author: User

Registry file associations and applications-the registry uses the full Raiders   a friend who likes to use Windows Right-click shortcut menu may know that when you select a file (or a folder or System icon) and then click the right mouse button, the system will pop up a menu, the menu above the various "functions" (or " Operation "is optional, but have you noticed that when you install some application software, your right button menu is not inflated, take WinZip as an example, after installing WinZip, the file or folder's right-click menu adds feature Selection" Add to zip "and" Add to xxx.zip ", as figure one, see this change, we can not help but ask how these options are added, you can add it yourself. With these questions, let's look at the file associations of Windows.   Diagram A What is a file association? In layman's parlance, it is the function items that are displayed on the right-click menu when selecting different types of files. Each feature item corresponds to an association. When a function (operation) is selected, the system executes the appropriate handler. It is recorded in the system registry as to what kind of handler is for what file. Therefore, to really understand the file association, you must study the registry in depth. If this problem is solved, we can use the registry to create, modify, and delete associations as we wish. Since the associated information is written in the registry, how does it form in the registry? We may wish to open the Registry and observe the respective primary keys under the root key HKEY_CLASSES_ROOT. (This may be easier to illustrate) do you see a lot of the front there is a point (.), which seems to be the primary key of the file name extension, as shown in Figure two, bat,.txt,.lnk,.bmp. We call the primary key of this class "extension primary key", each extension primary key has a default key value. For example, the default value for the primary key. BAT is the default value of the Batfile; .lnk primary key is Lnkfile. Given these two examples, do you see the rules. That is, if the "Extended primary key" name is. XXX (xxx is an extension of a certain type of file), then its default key value is Xxxfile. Of course, not all default values are the same, and multiple primary keys may correspond to the same default value. For example: Primary key. JPEG and PRIMARY key. jpg, their default values jpgfile;. The default values for HTML and HTM are htmlfile. Why do you have to say so many default values for the primary key of the extension? The reason for this and listen to me slowly way. This default key value is important, it is the bridge and link of file association, it is the type of file (with extension to identify file type) and file association. No, you can use the default key for an "extension primary key"If you change the value, you will find that many of the associated items in the class file are missing from the right-click menu. Since this important default key value plays a role as a bridge, then the other end of the bridge--how does the association of the file define it? We continue to look at the registry and let it explain to us. is still under the HKEY_CLASSES_ROOT root key. We can see the following primary key under the root key. such as:batfile,txtfile,lnkfile  and so on. (figure III) Figure Three these primary keys seem to be the default values for the "extension primary key" that we just mentioned. Yes, the above defaults have just become the primary key name here--this is the bridge. We refer to the primary key of this class as "identifying the primary key". In general, under "identify primary key" There are several important primary keys: (figure IV)   as Figure four DefaultIcon primary key, its function is to define the default icon for the class file.
The Shell primary key, its function is the center of this article discussion--The file association "the". The various associations of a file are parasitic under this "root", which defines the class file as being associated with multiple programs. Its default value is also very useful, do you remember to double-click the file to open the file (for registered files), this open is to use the system registry to set the default mode, that is, the default key value of the shell primary key control. Each primary key under it can be called an association primary key (as in Figure IV). The key name of the association primary key is arbitrary (recommended in English), and its default key value is also of interest to us. Because this default key value is displayed directly in the right-click menu, and there is a command primary key under each "Association primary key", the primary key defines "the corresponding execution program for the association." As shown in Figure five, the association to this file is already abundantly clear. Under Figure Five, we use the. reg file (the registry script file) as an example to illustrate its associated process. First, the. reg file has an "extension primary key" under the HKEY_CLASSES_ROOT Root key.. reg's default value is RegFile, which indicates that the primary key associated with the Reg type file is RegFile. Then under the root key to find "identity primary key" Regfile,regfile primary key under a Dfaulticon primary key, the role is to define a reg file default icon. The default key is the full path file name of the icon. such as: c:\windows\regedit.exe,1 (represents the 2nd icon in the Regedit.exe). There is also an association of the primary key Shell,reg file called "RegFile" below the primary key that is recorded in the shell. Let's set up an association for REGT below. Step: Under the Shell primary key, create a new primary key XXF (name any), place its default value: "Xu Xi Text Editor", and then under XXF Primary key to create a new primary key command, with its default value of C:\Windows\Notepad.exe% 1, The meaning of this default value is: Use Notepad to open the current reg file. If the%1 parameter is not present, only the Notepad program is run and the current file is not opened. Set up, you can look at the reg file "Right menu", is not more than a "Xu Xi text Editor" option (such as Figure VI), cool! ~
Figure six above is just an association that acts on a normal file, whereas in Windows, in addition to files, there are folders and special documents (such as My Computer, drive, Recycle Bin, etc.). So how do you set the correlation? Then please remember that under the HKEY_CLASSES_ROOT root key there are several important system Association primary keys: *: Acts on all files, and it is the same as the association method for identifying primary keys.
Directory: Works on general folders.
Folder: For all folders, including special files, such as: Control Panel, Recycle Bin and so on.
Drive: Acts on drives such as a drive, B drive, and C drive.
Unknow: A file type that is not recognized by the system, that is, a file type that is not registered. The most basic file association is here, let's look at the application of the file association. One application: Let MS-dos approach be ubiquitous. A friend who often uses DOS is a bit annoying, because every time you go to dos, choose Start \ program \ms-dos mode. With file associations, we can add MS-dos to the "right menu" of any file, which is much more convenient by:
Expand the registry to the Hkey_classes_root\*\shell branch. (Add MS-dos in the right-click menu of all files) create a new primary key, "MS-DOS," with the default of "Enter MS-DOS", and under the MS-DOS primary key, the new command primary key, and the default value: "C:\Windows\command.com ”。
The other registry expands to the Hkey_classes_root\folder\shell branch, (adding MS-dos in the right key menu of all folders) is set as above. Application bis: The small arrow in the shortcut icon is hidden. If you think a small arrow in the shortcut icon is a bit of a handicap, use the association to remove it, expand the registry to the Hkey_classes_root\lnkfile branch, delete the key value isshortcut the Lnkfile primary key, and then expand the registry to HKEY _classes_root\piffile Branch, the key value under the Piffile primary key Isshortcut deleted, that is done. Application three: Use Notepad to edit the bat file. Sometimes you want to edit a bat file, but it's a habit of double-clicking it, double-clicking it, and not opening it to the editor, but getting it done is annoying. You can change this by using the file association of 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. Application Four: Change the default icon for a class of files. Take TXT file as an example, change the icon of TXT file to "My Computer" icon. 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\explorer.exe,0"  . Application Five: Add "open mode" for all files. Expand the registry to the Hkey_classes_root\*\shell branch, create a new primary key open_as, set its default to "Choose Open Mode", and under Open_as primary key, create a new primary key command, with the default value: "C:windows\ rundll32.exe shell32.dll , openas_rundll %1 "Application of the Six:" Shut down the machine to the right button menu. Expand the registry to the Heky_classes_root\directory\shell branch, create a new primary key close, set its default to shutdown system, and, under the closing primary key, create a new primary key command, and set its default value to: "C:\Windows\ Rundll32.exe user.exe, exitwindows "Above six cases of application, the overall ability to outline the basic structure of the file association and the basic framework, to clarify the structure and framework of the file association, it is a piece of cake to add their own association. As long as you are interested, you canYour right button menu is full. If you want to know more about the file association of a deeper level, please refer to the books and information about the Windows registry, or contact me, my email is amen.twty@china.net. Before the end of the article, but also to tell you a little trick: that the registry has been modified, many occasions need to restart to take effect. Here I tell you a way to quickly change the registry without restarting it: Select Start \ Shutdown system, after the "Shut down system" box pops up, press ctrl+alt+del , the "End Task" box appears, select "Explorer", and then click "End Task". ", Wait a moment (10 seconds or so), there will be an" End Task "confirmation box, click the" End Task "button. (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.