zoukankan
html css js c++ java
Tencent://Message/协议的实现原理
腾讯官方通过 Tencent://Message/协议可以让QQ用户显示QQ/TM的在线状态发布在互联网上;并且点击 XXX ,不用加好友也可以聊天 官方链接: http://is.qq.com/webpresence/code.shtml 具体代码:
< 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_ROOTTENCENT] @=”TencentProtocol” “URL Protocol”=”D:\Program Files\Tencent\QQ\Timwp.exe” [HKEY_CLASSES_ROOTTENCENTDefaultIcon] @=”D:\Program Files\Tencent\QQ\Timwp.exe,1″ [HKEY_CLASSES_ROOTTENCENTshell] [HKEY_CLASSES_ROOTTENCENTshellopen] [HKEY_CLASSES_ROOTTENCENTshellopencommand] @=””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_ROOTfoo] @="URL:foo Protocol" "URL Protocol"="" [HKEY_CLASSES_ROOTfooshell] [HKEY_CLASSES_ROOTfooshellopen] [HKEY_CLASSES_ROOTfooshellopencommand] @=""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 FilesApplicationprogram.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
查看全文
相关阅读:
前端(基础篇)
面向对象
python(进阶篇)
Python(基础篇)
pycharm中添加python3 的环境变量
MySQL与MongoDB的不同
pycharm中添加python3 的环境变量
ContentType&CORS&Git
RESTful 组件
Django REST_framework Quickstart
原文地址:https://www.cnblogs.com/westsoft/p/5925961.html
最新文章
QListWidget列表控件:当鼠标选中某行时,系统会自动设置选中的行的行号,用currentRow()返回回来,没有setCheck或setSelect类似函数
QWidget、QMainWindow、QFrame、QWindow、QDialog、QScrollArea区别
pyqt5事件与鼠标事件
pyqt5信号与槽2
绘图工具--turtle模块
关于CMainFrm不接收鼠标事件响应原因
mfc设置鼠标状态OnSetCursor响应函数
理解SetCapture()和ReleaseCapture()及GetCapture()作用
让Mac OS X下的终端像Linux那样拥有丰富多彩的颜色显示
Linux主机被SSH精神病(Psychos)暴力攻破后成为肉鸡的攻防过程
热门文章
在Fedora 22下安装配置RealVNC Server 5.2.3的经验总结
GNOME 3.x下安装配置小企鹅输入法框架及SunPinYin插件
Objective C语言中nil、Nil、NULL、NSNull的区别
VirtualBox 5.0.10 中 Fedora 23 在安装了增强工具后无法自动调节虚拟机分辨率的问题(改)
在 VirtualBox 5.0 系列中让虚拟机支持 USB 3.0 必须开启 APIC
JVM CMS 常用参数配置(修订)
Mac OS X 10.10.5 中 VirtualBox 5.0 里的 Win7 虚拟机无法使用 USB 3.0 设备的解决办法(补充说明)
解决 Mac OS X Retina 屏幕显示环境下 jEdit 字体模糊的方法
Mysql
前端(进阶篇)
Copyright © 2011-2022 走看看