windows 默认电子邮件客户端在注册表中的设置方式和具体位置?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3940358/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How and where exactly does the default email client gets set in the registry?
提问by Hatch
In order to find out what the default email client is, I found the same information over and over again: Look at the default string in HKLM\Software\Clients\Mail
. (see for example this related question)
为了找出默认的电子邮件客户端是什么,我一遍又一遍地找到相同的信息:查看HKLM\Software\Clients\Mail
. (例如参见这个相关问题)
However, this seems not to be true for all OSs and/or situations: I have two machines running Win7 64bit, let's call them A and B. A has Outlook 2010 64bit and Thunderbird 3 32bit installed. B has Outlook 2007 32bit and Thunderbird 3 32bit installed. Both A and B have Thunderbird set as their default mail client.
但是,这似乎不适用于所有操作系统和/或情况:我有两台运行 Win7 64 位的机器,我们称它们为 A 和 B。A 安装了 Outlook 2010 64 位和 Thunderbird 3 32 位。B 安装了 Outlook 2007 32 位和 Thunderbird 3 32 位。A 和 B 都将 Thunderbird 设置为默认邮件客户端。
However, the state of the registry is not as I expected it:
但是,注册表的状态并不像我预期的那样:
On machine A, both HKLM\Software\Clients\Mail
and HKLM\Software\Wow6432Node\Clients\Mail
have an empty string as the default string value.
On B, both those keys contain Microsoft Outlook
as the default string value, which is clearly wrong.
Further investigation revealed that the correct value seems to be written to HKCU\Software\Clients\Mail
on both machines.
在机器 A 上,HKLM\Software\Clients\Mail
和HKLM\Software\Wow6432Node\Clients\Mail
都有一个空字符串作为默认字符串值。在 B 上,这两个键都包含Microsoft Outlook
作为默认字符串值,这显然是错误的。进一步调查显示,似乎HKCU\Software\Clients\Mail
在两台机器上都写入了正确的值。
I want my application to handle this correctly for all cases. It makes kinda sense, that Win7 now seems to hold a separate default mail client for each user, but it appears rather inconsistent. When looking at the plethora of information that points to HKLM\Software\Clients\Mail
, it seems obvious that previous versions of Windows handled this differently and always wrote to that location. So when did this change? Has the wrong value on machine B any meaning? If not, why does it get written there in the first place? Does the mix of 64bit and 32bit email clients on the same computer change anything?
我希望我的应用程序在所有情况下都能正确处理这个问题。有点道理,Win7 现在似乎为每个用户拥有一个单独的默认邮件客户端,但它看起来相当不一致。查看指向 的大量信息时,HKLM\Software\Clients\Mail
很明显以前版本的 Windows 处理此问题的方式不同并且总是写入该位置。那么这是什么时候改变的呢?机器 B 上的错误值有什么意义吗?如果没有,为什么它首先写在那里?在同一台计算机上混合使用 64 位和 32 位电子邮件客户端会改变什么吗?
I would most appreciate if anyone would share reliable information or documentation that explains this topic! Maybe there is a Win32 API function that returns the correct value?
如果有人能分享解释此主题的可靠信息或文档,我将不胜感激!也许有一个返回正确值的 Win32 API 函数?
回答by Dennis G
Does this MSDN article help you?
这篇 MSDN 文章对您有帮助吗?
How to Register an Internet Browser or E-mail Client With the Windows Start Menu
如何使用 Windows 开始菜单注册 Internet 浏览器或电子邮件客户端
Registrations made in the HKEY_CURRENT_USER subtree have higher precedence for the console user than corresponding registrations made in the HKEY_LOCAL_MACHINE. For new users on the system, the settings stored in HKEY_LOCAL_MACHINE are used.
对于控制台用户,在 HKEY_CURRENT_USER 子树中进行的注册比在 HKEY_LOCAL_MACHINE 中进行的相应注册具有更高的优先级。对于系统上的新用户,使用存储在 HKEY_LOCAL_MACHINE 中的设置。
For Windows XP a special article: How to modify the default Web browser and e-mail client programmatically in Windows XPand How to implement a per-user default mail client in Windows XP?
对于 Windows XP,有一篇特别文章:如何在 Windows XP 中以编程方式修改默认的 Web 浏览器和电子邮件客户端以及如何在 Windows XP中实现每个用户的默认邮件客户端?
Sorry, can't help you with the Win32 API.
抱歉,无法为您提供 Win32 API 的帮助。
回答by Yoav Feuerstein
For Windows 10, this seems to be different - see the discussion here: https://superuser.com/q/1045349/176339
对于 Windows 10,这似乎有所不同 - 请参阅此处的讨论:https: //superuser.com/q/1045349/176339
Quoting the relevant paragraph for your question, from papo's answer:
从papo的回答中引用您问题的相关段落:
Registry entries for mailto protocol are under HKLM\SOFTWARE\Classes\mailtoand as it is with other Classes, they could be overridden by entries for CURRENT_USER, under HKCU\SOFTWARE\Classes\mailtoBUT There were changes in recent Windows versions and now, there are more places in registry which will further override shell associations from Classes. Moreover, in case of mailto they are mandatory and so rendering the Classes values for mailto useless. Next in line of importance is Key: [HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\mailto]which in turn is overridden by: [HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\Roaming\OpenWith\UrlAssociations\mailto]which is also used only if it's not overridden by: [HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\Shell\Associations\UrlAssociations\mailto]
GOOD JOB Microsoft :) Values under these Keys have the same format, a Key UserChoice with a ProgId valuename pointing to shell association Key from Classes. But you can all but forget about editing these values, as there also is the Hash value. It's a protection against such registry edits. User MUST click himself at least once to select an App on a standard Windows Open With dialog popup, if he also check the Always option, the Hash value is generated and the choice is remembered and written to last two Keys from the list above. Another option is to use the Settings as shown in the picture above. It's a safeguard against malicious Apps, viruses and bad programmed Apps.
To troubleshoot a problem with default mailto association, you can delete mailto Keys from under all of these locations, except LOCAL_MACHINE. Windows will re-create them on next use of the mailto protocol.
mailto 协议的注册表项位于HKLM\SOFTWARE\Classes\mailto 下,并且与其他类一样,它们可以被CURRENT_USER的条目覆盖,位于HKCU\SOFTWARE\Classes\mailto但最近的 Windows 版本中发生了变化,现在,注册表中有更多位置将进一步覆盖类中的 shell 关联。此外,在 mailto 的情况下,它们是强制性的,因此使 mailto 的 Classes 值无用。紧随其后的是 Key: [HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\mailto],它又被覆盖: [HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\Roaming\OpenWith\UrlAssociations\mailto]仅当它未被覆盖时才使用: [HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\Shell\Associations\UrlAssociations\mailto]
微软干得好 :) 这些 Keys 下的值具有相同的格式,一个 Key UserChoice 和一个 ProgId valuename 指向来自 Classes 的 shell 关联 Key。但是您几乎可以忘记编辑这些值,因为还有哈希值。这是对此类注册表编辑的保护。用户必须至少单击自己一次以在标准的 Windows 打开方式对话框弹出窗口中选择一个应用程序,如果他还选中始终选项,则会生成哈希值,并记住选择并写入上面列表中的最后两个键。另一种选择是使用上图所示的设置。它是针对恶意应用程序、病毒和不良编程应用程序的保护措施。
要解决默认的 mailto 关联问题,您可以从所有这些位置(LOCAL_MACHINE 除外)下删除 mailto 密钥。Windows 将在下次使用 mailto 协议时重新创建它们。