浏览器调用桌面程序方法

来源:互联网 发布:小孩刘心悠原帖知乎 编辑:程序博客网 时间:2024/06/06 09:11
一、注册服务
1、说明

参见浏览器客服qq点击后唤起qq聊天窗口。其在注册表中添加如下信息,这个本身也是win自己支持的。其中 C:\\Program Files (x86)\\Tencent\\QQ\\Bin\\Timwp.exe 程序为接收信息程序,.net程序会在main方法 args[]中放入

Windows Registry Editor Version 5.00[HKEY_CLASSES_ROOT\Tencent]@="TencentProtocol""URL Protocol"="C:\\Program Files (x86)\\Tencent\\QQ\\Bin\\Timwp.exe"[HKEY_CLASSES_ROOT\Tencent\DefaultIcon]@="C:\\Program Files (x86)\\Tencent\\QQ\\Bin\\Timwp.exe,1"[HKEY_CLASSES_ROOT\Tencent\shell][HKEY_CLASSES_ROOT\Tencent\shell\open][HKEY_CLASSES_ROOT\Tencent\shell\open\command]@="\"C:\\Program Files (x86)\\Tencent\\QQ\\Bin\\Timwp.exe\" \"%1\""

telnet的注册信息
Windows Registry Editor Version 5.00[HKEY_CLASSES_ROOT\telnet]@="URL:Telnet Protocol""EditFlags"=dword:00000002"FriendlyTypeName"="@C:\\WINDOWS\\system32\\ieframe.dll,-907""URL Protocol"=""[HKEY_CLASSES_ROOT\telnet\DefaultIcon]@="C:\\Windows\\System32\\url.dll,0"[HKEY_CLASSES_ROOT\telnet\shell][HKEY_CLASSES_ROOT\telnet\shell\open][HKEY_CLASSES_ROOT\telnet\shell\open\command]@="\"C:\\Windows\\System32\\rundll32.exe\" \"C:\\Windows\\System32\\url.dll\",TelnetProtocolHandler %l"
2、bat工具
为此写好bat可执行文件写入注册表,分为xp和win7向上,以下拷贝到文本改为bat即可使用。
xp版本,和要注册的exe同目录即可。HKEY_CLASSES_ROOT\FINGARD二级目录为后续访问使用,可依据具体情况更改
@echo offset service=%cd%/posservice.exeset service2=%cd%\\posservice.exereg add HKEY_CLASSES_ROOT\FINGARD /ve /d "FingardProtocol" /freg add HKEY_CLASSES_ROOT\FINGARD /v "URL Protocol" /t REG_SZ /d "%service%" /freg add HKEY_CLASSES_ROOT\FINGARD\DefaultIcon /ve /d "%service%,1" /freg add HKEY_CLASSES_ROOT\FINGARD\shell /freg add HKEY_CLASSES_ROOT\FINGARD\shell\open /freg add HKEY_CLASSES_ROOT\FINGARD\shell\open\command /ve /d "\"%service2%\" \"%%1\"" /fpause
win7向上版本,和要注册的exe同目录即可,需要管理员权限运行。
@echo offset service=%~dp0\posservice.exeset service2=%~dp0\posservice.exereg add HKEY_CLASSES_ROOT\FINGARD /ve /d "FingardProtocol" /freg add HKEY_CLASSES_ROOT\FINGARD /v "URL Protocol" /t REG_SZ /d "%service%" /freg add HKEY_CLASSES_ROOT\FINGARD\DefaultIcon /ve /d "%service%,1" /freg add HKEY_CLASSES_ROOT\FINGARD\shell /freg add HKEY_CLASSES_ROOT\FINGARD\shell\open /freg add HKEY_CLASSES_ROOT\FINGARD\shell\open\command /ve /d "\"%service2%\" \"%%1\"" /fpause
二、处理类案例
.net环境使用c#编写代码如下,生成exe后即可为处理类。此为入口程序,解析传入的信息后在触发实际需求程序。
class Posservice{static void Main(string[] args){    Console.WriteLine(args[0]);   //读取行,让控制台等待   Console.ReadLine();}}

注:在vs中配置项目输出类型为控制台应用程序 会弹出黑框框,设置为 Windows应用程序 则不会再有黑框框弹出




三、调用示例
1、浏览器地址栏调用
在地址栏输入:fingard://Hello World....。调用命令为 fingard://,后续可跟字符串,调用后会将整个调用串传递给注册程序。

2、html中使用js调用。

<script>var series = "fingard://Hello World....";window.location=series;</script>







阅读全文
0 0
原创粉丝点击