简体   繁体   English

如何以编程方式创建在XP,Vista和Windows 7中工作的文件关联

[英]How to programmatically create a file association that works in XP, Vista and Windows 7

I want to be able to register my file-extension from my program. 我希望能够从我的程序中注册我的文件扩展名。 (Associate the filetype with my program) (将文件类型与我的程序关联)

There are lots of articles about this, but the technique discussed (fiddling with the registry) is only appropriate for Windows XP as far as I see. 有很多关于此的文章,但据我所知,所讨论的技术(摆弄注册表)仅适用于Windows XP。

What is the best way to associate a filetype with a program so that it works under XP, Vista and Windows 7 as well ? 将文件类型与程序关联以使其在XP,Vista和Windows 7下运行的最佳方法是什么? (Are there any working code-examples ?) (有没有工作代码示例?)

ClickOnce would be an option, but this only registers the filetype at installation-time while I want to be able to register filetypes at runtime. ClickOnce是一个选项,但这只在安装时注册文件类型,而我希望能够在运行时注册文件类型。

In Windows Vista (and presumably Windows 7) file associations have changed: if a file is already associated with a program and you reassociate it, doubleclicking the file won't open it with the new program. 在Windows Vista(可能是Windows 7)中,文件关联已更改:如果文件已与程序关联并重新关联,则双击该文件将无法使用新程序打开它。 Instead, the association is added to the list under "open with". 相反,关联将添加到“打开方式”下的列表中。 Also see this little discussion on registering your application for associations in Vista (Web Archive, original link is gone). 另请参阅关于在Vista中注册关联应用程序的小讨论(Web Archive,原始链接已不复存在)。

I'm not sure whether it is good to change this. 我不确定改变它是否有益。 However, this post discusses the various keys in the registry that you can use. 但是, 这篇文章讨论了您可以使用的注册表中的各种键。 But even better, this codeproject article gives you ready to use code for associating a file at runtime. 但更好的是, 这个代码项目文章让您准备好使用代码在运行时关联文件。 I don't know whether it works any differently on Vista+ though. 我不知道它在Vista +上是否有所不同。

If you need to add file association in a non admin scenario, you can use User-specific file associations which is described in this article . 如果需要在非管理方案中添加文件关联,则可以使用本文中介绍的特定于用户的文件关联。 Check out the " User-specific file associations ". 查看“ 用户特定的文件关联 ”。

There were only a couple changes from XP to Vista/7 as far as file association goes, so most examples for XP should still work. 就文件关联而言,从XP到Vista / 7只有一些变化,所以XP的大多数例子仍然有效。 The only think you should be concerned about is the 'Default Programs' setting in Vista/7 that did't exist in XP and overrides other file association registration. 唯一认为你应该关注的是Vista / 7中的“默认程序”设置在XP中不存在并覆盖其他文件关联注册。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Windows XP / Vista上获取包括SolidWorks在内的任何文件的缩略图 - Get thumbnail of any file including SolidWorks on Windows XP/Vista C#.Net 2.0我的编码可在Windows XP和Vista上使用,但不适用于Windows 7 - C# .Net 2.0 My Encoding works on Windows XP and Vista but not Windows 7 在Vista和Windows 7中而不是XP中的OLEDB JET错误 - OLEDB JET error in Vista & Windows 7, not in XP 以编程方式登录Windows XP - Login to Windows xp programmatically 添加应用程序清单以确保跨Windows XP,Vista和Windows 7的特权提升的可靠性如何? - How reliable is adding an application manifest to ensure elevated privileges across windows xp, vista and 7? 如何使用Visual Studio开发可在所有Windows OS XP,Vista,7、8上运行的C#应用​​程序 - How to develop c# application using visual studio which will run on all windows OS xp,vista,7,8 我如何在Windows(xp,vista,7)欢迎屏幕或锁定屏幕(如VNC或Dame Ware)中进行交互 - how can i interact in windows (xp, vista, 7) welcome screen or locked screen like a VNC or Dame Ware 在Windows XP上,以编程方式在单个c:驱动器上将Pagefile设置为“No Paging File” - On Windows XP, programmatically set Pagefile to “No Paging File” on single c: drive 如何在 windows xp 中创建自定义登录页面 - How to create custom login page in windows xp 检测XP,Vista或Windows 7,然后根据操作系统版本选择XAML样式 - Detect XP,Vista, or Windows 7 and select XAML style depending on version of OS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM