Windows文件关联正确完成了吗? [英] Windows file associations done properly?

查看:83
本文介绍了Windows文件关联正确完成了吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将我的应用程序设置为在Windows中具有文件关联(附加的复杂性:文件扩展名可能与其他一些不相关的应用程序冲突).处理这种情况的最佳方法是什么?用户很可能不会同时拥有这两者,但是如果他们同时拥有,最好的处理方式是什么?

I want to set up my application to have a file association in Windows (additional complication: the file extension could conflict with some other unrelated application). What is the best way to handle a situation like that? Most likely, a user wouldn't have both, but in the event that they do, what is the best way to proceed?

我一直在在线搜索stackoverflow和其他各种站点,并且对如何做到这一点有基本的了解(我已经尝试过了,而且行得通),但是找不到关于如何做到最好的明确参考

I've been searching stackoverflow and various other sites online, and have a basic idea of how to do this (I've tried it, and it works), but can not find a definitive reference on how this is best done.

一些参考文献说将条目放入HKEY_CLASSES_ROOT中的注册表中.有人说不要这样做,而是将其放入HKEY_LOCAL_MACHINE \ Software \ Classes.

Some references say put entries into the registry in HKEY_CLASSES_ROOT. Some say don't do that, and instead put it into HKEY_LOCAL_MACHINE\Software\Classes.

是否还需要在HKEY_LOCAL_MACHINE \ Software \ Microsoft \ Windows \ CurrentVersion \ App Paths或HKEY_CLASSES_ROOT \ Applications下注册该应用程序(并且相对于关于HKEY_CLASSES_ROOT与HKEY_LOCAL_MACHINE \ Software \ Classes的讨论,这在技术上还是正确的位置)以上)?

Does the application also need to be registered under HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\App Paths or HKEY_CLASSES_ROOT\Applications (and is this even the technically correct location with reference to the discussion about HKEY_CLASSES_ROOT vs HKEY_LOCAL_MACHINE\Software\Classes above)?

我还看到一些页面建议设置"CurVer"和"OpenWithProgids",但是我不确定它们会如何提供帮助.

I've also seen some pages advise about setting "CurVer" and "OpenWithProgids", but I'm not sure how they would help.

我发现我可以创建

HKEY_LOCAL_MACHINE \ Software \ Classes.aaa (默认)AAAapp

HKEY_LOCAL_MACHINE\Software\Classes.aaa (Default) AAAapp

HKEY_LOCAL_MACHINE \ Software \ Classes \ AAAapp (默认)AAAapp DefaultIcon%mypath%\ to \ AAAappIcon.ico" shell \ open \ command%mypath%\ to \ AAAapp.exe"%1"

HKEY_LOCAL_MACHINE\Software\Classes\AAAapp (Default) AAAapp DefaultIcon "%mypath%\to\AAAappIcon.ico" shell\open\command "%mypath%\to\AAAapp.exe" "%1"

,并且有效.我没有创建应用程序路径"或应用程序"注册表项,因此这些注册表项似乎不会对此产生影响.同样,以上内容似乎也无法很好地处理系统上已经存在".aaa"文件扩展名的关联的情况.

and it works. I didn't create the App Paths or Applications registry key, so those keys do not appear to affect this. As well, the above appears to have no provision for nicely handling the case where an association for an ".aaa" file extension already exists on the system.

任何指导表示赞赏!

推荐答案

旧问题-7.5个月没有答案-但以下内容可能会对将来的Google员工(例如我)有所帮助.

Old question -- no answer for 7.5 months -- but the following might help future googlers (like me).

HKEY_CLASSES_ROOT是

HKEY_CLASSES_ROOT is a combined view of

  • HKEY_ LOCAL_MACHINE \ Software \ Classes
  • HKEY_ CURRENT_USER \ Software \ Classes.
  • HKEY_LOCAL_MACHINE\Software\Classes
  • HKEY_CURRENT_USER\Software\Classes.

您不应该写HKEY_CLASSES_ROOT,而只能以只读方式使用它.另外,建议的做法是写入HKEY_CURRENT_USER \ Software \ Classes而不是HKEY_LOCAL_MACHINE,除非您确实需要为所有用户设置内容.

You're not supposed to write to HKEY_CLASSES_ROOT, just use it read-only. Also, the recommended practice is to write to HKEY_CURRENT_USER\Software\Classes rather than HKEY_LOCAL_MACHINE, unless you really need to set things for all users.

Microsoft的文档似乎很冗长和分散,因此我花了很长时间才完全确定自己需要为自己的小应用程序做些什么.但是,仍然最好先尝试使用官方文档(除非有人可以将我们指向可以更好地说明问题的地方),然后稍后再问是否有人无法理解.

Microsoft's documentation seems rather verbose and scattered, so it's taking me a long time to get settled on exactly what i need to do for my own little app. But still, it may be best to first try the official documentation (unless someone can point us to a place that explains things better), and ask questions later if one can't make sense of it.

Microsoft关于此区域的文档的入口点是 https://msdn.microsoft.com/library/windows/desktop/bg126469.aspx

The entry point for Microsoft's documentation about this area is "Desktop app technologies" at https://msdn.microsoft.com/library/windows/desktop/bg126469.aspx

对于文件类型注册,它导致我在 https://msdn.microsoft. com/en-us/library/windows/desktop/ff521657(v = vs.85).aspx

For file-type registration, it led me to "Implementing a Custom File Format" at https://msdn.microsoft.com/en-us/library/windows/desktop/ff521657(v=vs.85).aspx

从那里进入文件类型和文件关联",子菜单从那里涵盖您需要的一切(以及更多).

From there go into "File Types and File Associations", and from there the sub-menus cover everything you'll need (and more).

记住要写入HKCU \ Software \ Classes.似乎当在文档中编写HKEY_CLASSES_ROOT(HKCR)时,它通常只是作为引用(HKCU | HKLM)\ Software \ Classes的便捷方式.

Remember to write to HKCU\Software\Classes. It seems like when HKEY_CLASSES_ROOT (HKCR) is written in the docs, it's often just as a convenient way of referring to (HKCU|HKLM)\Software\Classes.

关于"HKEY_LOCAL_MACHINE \ Software \ Microsoft \ Windows \ CurrentVersion \ App路径"或"HKEY_CLASSES_ROOT \ Applications":

About "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\App Paths" or "HKEY_CLASSES_ROOT\Applications":

MS文档解释了它们与您已经使用的密钥之间的关系. (我仍然对此保持警惕,因此无法提供更直接的解释.)

The MS docs explain how they relate to the keys you've already used. (I'm still getting my head around it, so can't offer a more straightforward explanation.)

某些地方似乎说"App Paths"是首选,但实际上您可能需要同时使用两者,因为"App Paths"实际上仅与 paths 有关,而诸如 SupportedTypes FriendlyAppName 仅位于"HK(LM | CU)\ Classes \ Applications"中.

Some places seem to say "App Paths" is preferred, but actually you may need to use both, because "App Paths" really is only about paths, and things like SupportedTypes and FriendlyAppName are only in "HK(LM|CU)\Classes\Applications".

这篇关于Windows文件关联正确完成了吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆