如何注册自定义程序来处理 Windows 7 上的 mailto 协议
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7105258/
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 to register custom program to handle mailto protocol on Windows 7
提问by John
OK, it might be a problem with my system but I'm having a very difficult time getting Windows 7 to recognize my custom exe as the default handler of the mailto protocol.
好的,这可能是我的系统有问题,但我很难让 Windows 7 将我的自定义 exe 识别为 mailto 协议的默认处理程序。
First, I've seen this: Register Windows program with the mailto protocol programmatically
首先,我见过这个: Register Windows program with the mailto protocol programmatically
Next, I've seen these:
接下来,我看到了这些:
- How to Register an Internet Browser or Email Client With the Windows Start Menu
- Registering an Application to a URL Protocol
I've added what seemed the appropriate registry entries but I still get Windows Live Mail coming up every time I click a mailto link (whether in a browser or via the Run window). I've set the registry entries for all users and for the current user, still it doesn't work.
我已经添加了看似合适的注册表项,但每次单击 mailto 链接(无论是在浏览器中还是通过运行窗口)时,Windows Live Mail 仍然出现。我已经为所有用户和当前用户设置了注册表项,但它仍然不起作用。
When I go to the 'default programs' app and scroll down to the mailto protocol, I only see Outlook and Windows Live Mail listed. My custom app doesn't even appear.
当我转到“默认程序”应用程序并向下滚动到 mailto 协议时,我只看到列出了 Outlook 和 Windows Live Mail。我的自定义应用程序甚至没有出现。
I figure that it's either something special with Windows 7 or it's something with my computer.
我认为这要么是 Windows 7 的特殊之处,要么是我的计算机的问题。
My custom app is a WinForms .Net app but I don't think that matters.
我的自定义应用程序是 WinForms .Net 应用程序,但我认为这并不重要。
Any ideas are greatly welcome.
任何想法都非常受欢迎。
采纳答案by Oleg
The way described in the answerwhich you referenced in your question seems correct way for Windows 7 as for other operation systems.
您在问题中引用的答案中描述的方式对于 Windows 7 和其他操作系统来说似乎是正确的方式。
I suppose that you use 64-bit version of Windows 7 and your program is 32-bit application. So if your application write in the HKEY_LOCAL_MACHINE\SOFTWARE\Classes\mailto\shell\open\command
key it modifies only the key HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Classes\mailto\shell\open\command
used for 32-bit applications. You can read more about registry virtualisation hereand here.
我假设您使用的是 64 位版本的 Windows 7,并且您的程序是 32 位应用程序。因此,如果您的应用程序写入HKEY_LOCAL_MACHINE\SOFTWARE\Classes\mailto\shell\open\command
密钥,它只会修改HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Classes\mailto\shell\open\command
用于 32 位应用程序的密钥。您可以在此处和此处阅读有关注册表虚拟化的更多信息。
If it's your case you can call directly native Win32 API RegOpenKeyExwith the KEY_WOW64_64KEYflag which will be ignored on 32-bit operation system.
如果是您的情况,您可以使用KEY_WOW64_64KEY标志直接调用本机 Win32 API RegOpenKeyEx,该标志在 32 位操作系统上将被忽略。
回答by uluorta
Though a pretty late answer, what worked out for me is this: On regedit, this supersedes the registry keys mentioned in other answers:
虽然答案很晚,但对我来说是这样的:在 regedit 上,这取代了其他答案中提到的注册表项:
HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\URLAssociations\MAILTO\Userchoice
HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\URLAssociations\MAILTO\Userchoice
Have a look at this page: Default Mailto Registry
看看这个页面: 默认Mailto Registry
回答by ransom bot
回答by Anthony
This seems like a very high-nerd-level context to a fairly common problem. As a nerd, I'm swept up by the discourse on 64 vs x86 and the pseudo-universal binary aspects of .net. But the tech support troubleshooter in me can't help but think that the core problem needs to be made plain and addressed systematically...
对于一个相当普遍的问题,这似乎是一个非常高级的上下文。作为一个书呆子,我被 64 vs x86 和 .net 的伪通用二进制方面的论述所吸引。但是我里面的技术支持疑难解答不禁认为核心问题需要说清楚并系统地解决......
So your real problem, regardless of the mail client (as you said yourself), and regardless of your CPU, is that you can't get your mail client to be the default protocol handler for mailto. Or to make it really simple, you can't get the program you like to be the default program.
所以你真正的问题,不管邮件客户端(正如你自己所说的),不管你的 CPU,是你不能让你的邮件客户端成为 mailto 的默认协议处理程序。或者说真的很简单,你不能让你喜欢的程序成为默认程序。
I'm inclined to think that the 64/86 aspects of the problem are not relevant. They are interesting, and possibly having some effect, but if the program is running just fine (no issues with the code in that architecture, etc), and if it does email just fine (emails get send and received, all SMTP and IMAP all the way), then I doubt the OS is plotting to keep the client from taking over as the leader of the porch dogs.
我倾向于认为问题的 64/86 方面不相关。它们很有趣,并且可能有一些效果,但是如果程序运行得很好(该体系结构中的代码没有问题等),并且如果它可以很好地发送电子邮件(发送和接收电子邮件,所有 SMTP 和 IMAP 都方式),那么我怀疑操作系统是否正在密谋阻止客户接管作为门廊狗的领导者。
If anything, I would say that the client had self-esteem issues and is afraid to be the mailto protocol handler. Most clients can't resist asking if the should be the primary and if you say yes, they pass the word along to the other apps and to the registry. They make sure everyone knows they are the new Mailbox king in the house.
如果有的话,我会说客户有自尊问题,并且害怕成为 mailto 协议处理程序。大多数客户无法抗拒询问是否应该是主要的,如果您说是,他们会将这个词传递给其他应用程序和注册表。他们确保每个人都知道他们是家里的新邮箱之王。
So, what I would try first (basic troubleshooting): install another mail client and see if it has the same issue. If it does, your OS is a bully and you'll want to explore such routes.
所以,我会先尝试什么(基本故障排除):安装另一个邮件客户端,看看它是否有同样的问题。如果是这样,你的操作系统就是一个恶霸,你会想要探索这样的路线。
But if this other client can get into the default programs club and be made the mailto handler, then the problem is with your app. It's a big wimp that doesn't know how to properly assert himself.
但是,如果这个其他客户端可以进入默认程序俱乐部并成为 mailto 处理程序,那么问题就出在您的应用程序上。这是一个不知道如何正确维护自己的大懦夫。
But like so many underdogs waiting for a cool kid to take them under their wing (and by wing, I mean Thunderbird. Don't bother with any other client), your app can stand on the shoulders of the working third-party client.
但是,就像许多失败者在等待一个很酷的孩子把他们带在他们的翅膀下(我说的翅膀,我的意思是 Thunderbird。不要打扰任何其他客户端),您的应用程序可以站在工作的第三方客户端的肩膀上。
We have to assume that Thunderbird did at least one and possibly two things that your app didn't do. The first was getting it's name tied to the protocol in the registry. Go poke around and see if you can find his name and how it's associated to the mailto protocol. Chances are good that you can swap out his name for yours, or at the very least try to pin the protocol to you as well.
我们必须假设 Thunderbird 至少做了一件或两件你的应用没有做的事情。首先是将其名称与注册表中的协议相关联。四处看看,看看你是否能找到他的名字以及它是如何与 mailto 协议相关联的。很有可能你可以用他的名字代替你的名字,或者至少尝试将协议固定在你身上。
The second thing that T-Bird may have done was get himself in the "Default Programs" list (a feature of 7 that I didn't really like, because it had a cool concept behind it -- ie, let's group apps together up front rather than wait and see every time if one of them can do a similar job. But Windows screwed that good time (big surprise) by acting like the overprotective parent it always is, and showing up at the kids' party and saying "I think these two should be in this group, don't you?"
T-Bird 可能做的第二件事是让自己进入“默认程序”列表(我不太喜欢 7 的一个功能,因为它背后有一个很酷的概念——即,让我们将应用程序组合在一起如果他们中的一个人可以做类似的工作,而不是每次都等待和观察。但是 Windows 通过表现得像一个过分保护的父母,总是这样,并出现在孩子们的聚会上并说“我觉得这两个人应该在这个群里吧?”
Well, my hope is that by getting access to the mailto by borrowing it from Thunderbird, that you'll be welcomed into the default programs club, but if you aren't and you are still the mailto handler, I'd write it off, at least gloat about it for a week or two, before trying to tackle that issue.
好吧,我希望通过从 Thunderbird 借来访问 mailto,你会受到默认程序俱乐部的欢迎,但如果你不是并且你仍然是 mailto 处理程序,我会把它注销,在尝试解决该问题之前,至少要幸灾乐祸一两个星期。
Now, if Thunderbird can't get mailto control, I'm very inclined to think that Windows 7 as actually put in to place some sort of strange caste system, where the application and it's installer (eg user) must some how prove their worthiness to be in the group by figuring out what the big secret is.
现在,如果 Thunderbird 无法控制邮件,我很倾向于认为 Windows 7 实际上是为了放置某种奇怪的种姓系统,应用程序和它的安装程序(例如用户)必须如何证明它们的价值通过弄清楚什么是大秘密来加入团队。
Oh, and if all else fails, try restarting in Safe Mode with no networking, install your client in that environment, and starting it up. See if you can't make it the default while the others are in suspended animation. Do a test run (with no network, obviously) by writing a basic HTML page with a mailto and see if clicking on it opens your client.
哦,如果一切都失败了,请尝试在没有网络的安全模式下重新启动,在该环境中安装您的客户端,然后启动它。看看你是否不能在其他人处于假死状态时将其设为默认值。通过使用 mailto 编写一个基本的 HTML 页面来进行测试运行(显然没有网络),看看单击它是否会打开您的客户端。
THen cross your fingers when you start back up in normal mode.
然后在正常模式下启动备份时交叉手指。
Let me know if any of the above proved the least bit helpful.
如果以上任何一项被证明有一点帮助,请告诉我。