How does Windows know which program opens the file?

I just noticed that when I view .sln files on my computer, some have the v7.1 icon, some have the v9 icon, and some have the v10 icon (depending on which version of Visual Studio created them). Windows seems to be differentiating which files it receives, which icons, perhaps through some kind of β€œMIME” for files other than the extension.

Can I use this function to determine which file type the user selects from the MFC SaveAs default dialog box if the two file types share the extension?

+4
source share
1 answer

In the case of Visual Studio, the .sln files are associated with the Microsoft Visual Studio Version Selector, which is installed on my computer under "C: \ Program Files \ Common Files \ microsoft shared \ MSEnv \ VSLauncher.exe"

This executable should analyze the solution file to determine the version, and then present the icon on the right in Explorer.

In general, file associations for a given file type are present in the registry under HKEY_CLASSES_ROOT .

But in your case, I think you just need to read the contents of the file to determine which one it is. I hope there is something easily distinguishable between them.

+2
source

Source: https://habr.com/ru/post/1479625/


All Articles