Friends who like to use Windows right-click shortcut menus 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") you choose, but whether you notice, When you install some application software, your right-click menu is not inflated, take WinZip as an example, after installing WinZip, the file or folder of the right Key menu added feature options "Add to Zip" and "Add to Xxx.zip", as shown in figure I, see this change, We can not help but ask how these options are added, you can add them yourself. With these questions, let's look at the file associations of Windows.
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 with a dot (.), which looks like a primary key to the file name extension, as shown in Figure two
DefaultIcon the primary key, which functions as the default icon for defining 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.
Here's an example of a. reg file (a registry script file) 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. For example: C:windows egedit.exe,1 (represents the 2nd icon in 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:windowsnotepad.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 a "Xu Xi text Editor" option (as Figure VI)