参考网址:
http://blog.csdn.net/eroswang/article/details/1594795
http://hi.baidu.com/pluto632/item/5007737da31344326f29f666
http://msdn.microsoft.com/en-us/library/aa767914.aspx#prot_sec
http://msdn.microsoft.com/en-us/library/ie/aa767914(v=vs.85).aspx
http://kb.mozillazine.org/Register_protocol
http://superuser.com/questions/162092/how-can-i-register-a-custom-protocol-with-xdg
https://support.shotgunsoftware.com/entries/86754-How-to-launch-external-applications-using-custom-protocols-rock-instead-of-http-
针对ubuntu
1:
All Firefox versions (Requires certain Gnome libraries to be installed) In a terminal, type: gconftool-2 -s /desktop/gnome/url-handlers/foo/command '/path/to/app %s' --type String gconftool-2 -s /desktop/gnome/url-handlers/foo/enabled --type Boolean true Replace foo on both lines with the protocol you want to register and /path/to/app with the path to the application you want to run.
以上如果不行,可以试试一下操作
gconftool-2 -t string -s /desktop/gnome/url-handlers/foo/command 'foo "%s"'
gconftool-2 -s /desktop/gnome/url-handlers/foo/needs_terminal false -t bool
gconftool-2 -s /desktop/gnome/url-handlers/foo/enabled true -t bool
2:
在firefox地址栏输入about:config,出现如下界面
之后firefox version >3.5 执行一下操作
在preference name 下面,右键-》new,选择不同的类型建立不同的值
主要是如下几个值:
最后的testfile,要替换成你自己的协议。
并且要确保network.protocol-handler.expose-all 为true
3.
建立应用程序的桌面文件:/usr/share/applications/testfile.desktop (文件名称应该要与协议名称一样)
内容如下:
[Desktop Entry] Encoding=UTF-8 Name=testfile Comment=testfile Exec=/home/ubuntu/workspace/test_file/Debug/test_file %u Terminal=false StartupNotify=true Type=Application Categories=Application;Internet; Name[en_US]=testfile
之后在 /etc/gconf/gconf.xml.defaults/%gconf-tree.xml文件中添加以下内容
x-cheme-handler/testfile=testfile.desktop application/x-testfile=testfile.desktop application/testfile=testfile.desktop
然后在~/.local/share/applications/mimeapps.list文件中添加以下内容
[Default Applications] //这一行必须要有
x-scheme-handler/testfile=testfile.desktop application/x-testfile=testfile.desktop application/testfile=testfile.desktop
4.
之后在firefox地址栏中输入testfile://就能弹出你想要打开的程序