Generally, clicking an MP3 file will automatically call mediaplayer for playback.
If needed, we can also call our own program to process a file in a specific format.
First, process the registry.
For example, we need to associate the file with the suffix. dat. First, create a subdirectory under hkey_classes_root. dat, name is default, and data is datfile. Next, create a subdirectory datfile under hkey_classes_root, and create two subdirectories under datfile: defaulticon and shell. If there is no requirement for the file display icon, defaulticon uses the default value, and shell creates an Open Directory, open and create the command directory again. Here, you can specify the program to which the file is associated, for example, "/program files/test.exe" "% 1". Note that quotation marks must be added.
Changes to the Registry have come to an end.
Now, click the. dat file to activate the associated program.
But how does the program know which file to associate? The getcommandline () function returns the file path. It is worth noting that each time you click the. dat file, a new program instance is activated. That is to say, getcommandline () only works at the mian entrance. So when a program instance a is activated, if you click the. dat file, how does one get A's file path? I believe that everyone will come up with a variety of smart methods to achieve this.