windows 通过安装程序将应用程序注册到 URL 协议(所有浏览器)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/364895/
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
Register an application to a URL protocol (all browsers) via installer
提问by Greg Dean
I know this is possible via a simple registry change to accomplish this as long as IE/firefox is being used. However, I am wondering if there is a reliable way to do so for other browsers,
我知道只要使用 IE/firefox,就可以通过简单的注册表更改来实现这一点。但是,我想知道对于其他浏览器是否有可靠的方法可以做到这一点,
I am specifically looking for a way to do this via an installer, so editing a preference inside a specific browser will not cut it.
我正在寻找一种通过安装程序执行此操作的方法,因此在特定浏览器中编辑首选项不会削减它。
采纳答案by Greg Dean
Here is the best I can come up with:
这是我能想到的最好的:
IE: http://msdn.microsoft.com/en-us/library/aa767914(VS.85).aspx
IE:http: //msdn.microsoft.com/en-us/library/aa767914(VS.85).aspx
FireFox: http://kb.mozillazine.org/Register_protocol
火狐:http: //kb.mozillazine.org/Register_protocol
Chrome: Since every other browser in seems to support the same convention, I created a bugfor chrome.
Chrome:由于似乎所有其他浏览器都支持相同的约定,因此我为 chrome创建了一个错误。
Opera: I can't find any documentation, but it appears to follow the same method as IE/Firefox (see above links)
Opera:我找不到任何文档,但它似乎遵循与 IE/Firefox 相同的方法(见上面的链接)
Safari: Same thing as opera, it works, but I can't find any documentation on it
Safari: 与歌剧一样,它可以工作,但我找不到任何关于它的文档
回答by ka3yc
If someone looks like a solution for an intranet web site (for all browsers, not only IE), that contains hyperlinks to a shared server folders (like in my case) this is a possible solution:
如果有人看起来像是 Intranet 网站的解决方案(适用于所有浏览器,不仅是 IE),其中包含指向共享服务器文件夹的超链接(如我的情况),这是一个可能的解决方案:
- register protocol (URI scheme)via registry (this can be done for all corporative users i suppose). For example, "myfile:" scheme. (thanks to Greg Dean's answer)
The hyperlink href attribute will then should look like
<a href='myfile:\mysharedserver\sharedfolder\' target='_self'>Shared server</a>
Write a console application that redirects argument to windows explorer (see step 1 for example of such application)
- 通过注册表注册协议(URI 方案)(我想这可以为所有公司用户完成)。例如,“myfile:”方案。(感谢 Greg Dean 的回答)
超链接 href 属性应该看起来像
<a href='myfile:\mysharedserver\sharedfolder\' target='_self'>Shared server</a>
编写一个控制台应用程序,将参数重定向到 Windows 资源管理器(有关此类应用程序的示例,请参见步骤 1)
This is piece of mine test app:
这是我的测试应用程序的一部分:
const string prefix = "myfile:";
static string ProcessInput(string s)
{
// TODO Verify and validate the input
// string as appropriate for your application.
if (s.StartsWith(prefix))
s = s.Substring(prefix.Length);
s = System.Net.WebUtility.UrlDecode(s);
Process.Start("explorer", s);
return s;
}
I think this app can be easily installed by your admins for all intranet users :)
我认为您的管理员可以为所有 Intranet 用户轻松安装此应用程序 :)
I couldn't set up scheme setting to open such links in explorer without this separate app.
如果没有这个单独的应用程序,我无法设置方案设置以在资源管理器中打开此类链接。
回答by w4g3n3r
Yes. Here is how to do it with FireFox:
是的。以下是使用 FireFox 执行此操作的方法:
http://kb.mozillazine.org/Register_protocol
http://kb.mozillazine.org/Register_protocol
and Opera:
和歌剧: