是否有一个Windows API来修改文件类型关联延​​期?文件类型、有一个、Windows、API

2023-09-03 04:10:35 作者:特别关心

我在寻找一种方法以编程方式调整文件关联的细节在Windows系统上。例如,应用程序用户来执行此操作设置为开放式的行动为特定的文件类型。

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.

显然,我能做到这一点通过直接修改注册表,但如果有一个API,我倒是preFER使用,由于它可能会更加适应应用程序变化映射扩展的操作系统处理。

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.

对于我而言,我需要写这在VBScript(.VBS)文件,因为它是一个包的一部分进行使用VMware ThinApp的强制要求其使用。不过,我会口/包装/无论我需要做这个星期,所以我愿意接受任何解决方案(包括使用.NET Framework)

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)

推荐答案

微软的文件中,对创建文件关联的正式程序是通过注册表进行修改。你需要调用的唯一API是SHChangeNotify,与 SHCNE_ASSOCCHANGE ,告诉运行协会已经改变了应用程序。

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.