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