I'm looking for a way to programatically tweak the particulars of a file association on a Windows system. For example, the "Application User to Perform this Action" setting for the "Open" action for a particular file type.
Clearly I could do this by modifying the registry directly, but if there is an API I'd prefer to use that as it would likely be more resilient to changes in the OS handling of mapping extensions to applications.
For my purposes I'm needing to write this in VBScript (.VBS) file because it is part of a package to be used with VMWare ThinApp that mandates it. However, I'll port/wrap/whatever I need to make this week, so I am open to any solution (including using the .NET framework)
Microsoft documents that the official procedure for creating file associations is through modification of the registry. The only other API you need to call is SHChangeNotify, with SHCNE_ASSOCCHANGE
, to tell running applications that associations have changed.
Have a look at this answer: Windows Registry file association menu
The file associations are in the registry.
来源:https://stackoverflow.com/questions/1446879/is-there-a-windows-api-to-modify-file-type-associations-for-an-extension