Windows salad: implementation principle of File Association

Source: Internet
Author: User

When you double-click a file in Windows, if a program is associated with the file extension, the associated program is used to open the file. How is it implemented internally? I will give you a brief introduction today.

Everything is in the Registry

All registered extensions are in the Windows registry and their key values are located:

HKEY_CLASSES_ROOT

For example, you can see that there are many registry key values:

Let's dig down the key value of .txt:

It is strange that no program is found to open the key value.

OSS is on the default value of. txt. Please refer to the default value of. txt:

The default value of. txt is:

Txtfile

So what is this txtfile? In fact, txtfile is also a key value located under HKEY_CLASSES_ROOT. Its path is:

HKEY_CLASSES_ROOT \ txtfile

Let's take a look at what txtfile is:

No. Here is a sub-entry of shell \ open \ command. open this entry again to see:

As you can see, notepad.exe is "Notepad", and % 1 is generally used to pass the opened file path.

I find this and I guess this is the default program to open.

Practice Verification

The above is a conjecture. You still need to verify it.

I created a new. test extension and registered this type as testfile.

Create another testfile entry:

Test:

Summary

First, in Windows, check whether the corresponding extension has been registered in the registry. If there is a registration, read the file type corresponding to the extension, find the file type, and then read the associated program from it, to open the program.

Source: Greenerycn

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.