腾讯官方通过 Tencent://Message/协议可以让QQ用户显示QQ/TM的在线状态发布在互联网上;并且点击 XXX  ,不用加好友也可以聊天

官方链接: http://is.qq.com/webpresence/code.shtml

具体代码:
<a href="tencent://message/?uin=215555521&Site=JooIT.com&Menu=yes"> < img border="0" SRC='http://wpa.qq.com/pa?p=1:215555521:3' alt="点击这里给我发消息"> < /a>

但它是如何实现的呢?下面文章以及微软官方说明详细解释了其工作原理:


微软官方说明:http://msdn.microsoft.com/library/default.asp?url=/workshop/networking/pluggable/overview/appendix_a.asp

Register protocol,此文中对于 Windows、Linux 和 OS X 操作系统如何注册协议都有说明。比如说 Windows,其实只需写入注册表,即可实现协议与执行程序的关联。例如腾讯的Tencent://Message协议注册表如下:
[HKEY_CLASSES_ROOT\TENCENT] @=”TencentProtocol” “URL Protocol”=”D:\\Program Files\\Tencent\\QQ\\Timwp.exe”
[HKEY_CLASSES_ROOT\TENCENT\DefaultIcon] @=”D:\\Program Files\\Tencent\\QQ\\Timwp.exe,1″
[HKEY_CLASSES_ROOT\TENCENT\shell]
[HKEY_CLASSES_ROOT\TENCENT\shell\open]
[HKEY_CLASSES_ROOT\TENCENT\shell\open\command] @=”\”D:\\Program Files\\Tencent\\QQ\\Timwp.exe\” \”%1\”"
此注册表所实现的就是当浏览器(或其它)碰到 tencent://… 时,自动调用 Timwp.exe,并把 tencent://… 地址作为第一个参数传递给 Timwp.exe。
更多参见:Registering an Application to a URL Protocol。 
附:原文

程序代码:
A protocol is a method that is used to send, receive, and handle information over a connection. Common protocols viewed from the browser include http, ftp, and mailto. In order for you to view information sent over a specific protocol, it must be registered. Once registered, the protocol can then be handled by the program you specify, such as your browser or a 3rd party viewer. This means that a hyperlink ( e.g. foo://fred ) can use the handler for protocol foo to open the file named fred. 
Contents [hide] 1 Registering an unsupported protocol 1.1 Windows 1.2 Linux 1.3 OS X 2 Redirecting a registered protocol

[edit]Registering an unsupported protocol Mozilla products utilize protocols defined internally, as well as those defined by the operating system. You can add the ability to use an unsupported protocol by registering it. The OS-specific method of doing this is described below. 
[edit]Windows Create the registry .reg file, replacing foo with your unregistered protocol, and the path with whatever handler program you want to run. Then merge it into the Windows registry.
REGEDIT4
[HKEY_CLASSES_ROOT\foo] @="URL:foo Protocol" "URL Protocol"=""
[HKEY_CLASSES_ROOT\foo\shell]
[HKEY_CLASSES_ROOT\foo\shell\open]
[HKEY_CLASSES_ROOT\foo\shell\open\command] @="\"C:\\Program Files\\Application\\program.exe\" \"%1\"" See Registering an Application to a URL Protocol for additional information. 
[edit]Linux Registration is unnecessary. Simply associate whatever proto: with a program through Firefox: Example: Add the sip: protocol to launch kphone for VoIP calls in Firefox: 
- Type about:config into the address bar - Right-click create new boolean value: network.protocol-handler.external.sip and set to true - Right-click create new boolean value: network.protocol-handler.warn-external.sip and set to false - Right-click create new string value: network.protocol-handler.app.sip and set to /usr/bin/kphone This will actually launch kphone. Not sure if it will dial though. That is untested :) 
You can also optionally register the protocol with whatever window manager you are using. In KDE this is done through Control Center - KDE Components - File Associations. This step is usually unnecessary unless your window manager has a custom browser, such as konqueror. 
[edit]OS X Probably very similar to Linux (above). 
[edit]Redirecting a registered protocol If the protocol is already handled by the browser, you can specify what program will be used as a handler to open the file. To do this, add the pref: network.protocol-handler.app.foo as a string with value C:\Program Files\Application\program.exe Note: If the path or name is incorrect, the browser will display an error saying "protocol (foo) isn't associated with any program". (See bug 312953).
You may also need to use the following prefs, although this is uncertain: network.protocol-handler.external.foo = true network.protocol-handler.expose.foo = false

http://www.cnblogs.com/key-ok/p/3896338.html

Tencent://Message/协议的实现原理(Windows提供协议注册)的更多相关文章

  1. tencent://message协议

    tencent://message协议 |举报|字号 订阅     相信很多朋友在访问别人的博客.网上商城时可能会发现上都有这样的小玩意, 点击下就可以弹出对话框和主人进行对话,而且无需加对方为好友. ...

  2. Tencent://Message/协议的实现原理

    腾讯官方通过 Tencent://Message/协议可以让QQ用户显示QQ/TM的在线状态发布在互联网上:并且点击 XXX  ,不用加好友也可以聊天 官方链接: http://is.qq.com/w ...

  3. 由Tencent://Message协议想到的一个解决方案

    参考网址:http://www.cnblogs.com/phinecos/archive/2009/03/06/1404951.html 源代码下载:http://files.cnblogs.com/ ...

  4. [转]由Tencent://Message协议想到的一个解决方案

    源代码下载:http://files.cnblogs.com/phinecos/HelloWorldProtocal.rar 前天在BruceZhang的一篇博文<求助:如何在ASP页面中调用W ...

  5. Windows下ARP协议的工作原理简介

       ARP协议(Address Resolve Protocol,地址解析协议)工作在TCP/IP协议的第二层-数据链路层,用于将IP地址转换为网络接口的硬件地址(媒体访问控制地址,即MAC地址). ...

  6. 转战物联网·基础篇05-通俗理解MQTT协议的实现原理和异步方式

      网络上搜索MQTT协议,会出现太多的解释,这里就不做官方标准释义的复制了.这一节我们从实战理解角度,通俗的将MQTT协议的作用及实现原理说一下,旨在可以快速理解MQTT协议.所以可能会出现很多看似 ...

  7. C#综合揭秘——通过修改注册表建立Windows自定义协议

    引言 本文主要介绍注册表的概念与其相关根项的功能,以及浏览器如何通过连接调用自定义协议并与客户端进行数据通信.文中讲及如何通过C#程序.手动修改.安装项目等不同方式对注册表进行修改.其中通过安装项目对 ...

  8. SPI协议及工作原理分析

    说明.文章摘自:SPI协议及其工作原理分析 http://blog.csdn.net/skyflying2012/article/details/11710801 一.概述. SPI, Serial ...

  9. HTTPS 协议降级攻击原理

    0x00 HTTPS 在传统流行的web服务中,由于http协议没有对数据包进行加密,导致http协议下的网络包是明文传输,所以只要攻击者拦截到http协议下的数据包,就能直接窥探这些网络包的数据. ...

随机推荐

  1. cordova之File Transfer (Permission denied) 权限导致下载失败 - 简书

    原文:cordova之File Transfer (Permission denied) 权限导致下载失败 - 简书 在文件上传时,由于权限问题,会报错(Permission denied),安卓6. ...

  2. Read-Copy Update Implementation For Non-Cache-Coherent Systems

    A technique for implementing read-copy update in a shared-memory computing system having two or more ...

  3. Error: unrecognized flag -version

    按照网上的教程http://www.ituring.com.cn/article/13473 来确认node.js是否成功安装. 须要在命令行输入:node -version. 但是我在命令行输入:n ...

  4. 苹果抛弃的芯片公司Imagination被中资49亿溢价收购

    原标题:中国资本Canyon Bridge出资5.5亿英镑收购Imagination芯片 来源:观察者网 对于一家手机硬件公司来说,被苹果看上可谓是“一夜之间,鸡犬升天”.但是如果被苹果抛弃了呢?那可 ...

  5. 于CentOS 6.5编译器安装Git 1.8

    yum install git版本号是太老,它是1.7.1. 在这里,我们将介绍如何编译和安装Git 1.8 yum install curl-devel expat-devel gettext-de ...

  6. Redmine迁移至华为软件开发云-项目管理

    一.方案概述 要想将Redmine中某个项目的数据导入到华为软件开发云(以下简称开发云),如果说是按照Redmine中的数据一条一条的在开发云中新建出来,肯定不是一个明智的方案,下面就是给大家介绍一个 ...

  7. 设计模式在JDK中的应用

    在JDK(Java Development Kit)类库中,开发人员使用了大量设计模式. 创建型模式: (1) 抽象工厂模式(Abstract Factory) • java.util.Calenda ...

  8. 10g RAC 采用service达到taf

    service由于oracle数据库中的一个关键概念,利用得当,可以轻松地管理数据库,提高数据库的工作效率. 经service.oracle可以实现server side  taf,简单化client ...

  9. options.parse === void 0

    if (options.parse === void 0) options.parse = true; https://developer.mozilla.org/zh-CN/docs/Web/Jav ...

  10. python 快速排序 完整

    两头开始 以第一个为基准,从有往左,找第一个比基准数 大的,然后交换 从左往右,找第一个比基准数晓得,然后交换 遍历剩下的 基准数  左边的数们  以及  基准数 右边的数们 def quick_so ...