URL Protocol应用
来源:互联网 发布:武汉java 编辑:程序博客网 时间:2024/06/05 07:59
最近见一资源管理系统使用web与win32的窗口进行通信感觉挺有意思,偶尔在购物网站看到了QQ消息的弹窗效果
类似这样点击后弹出QQ消息窗口
然后google下 有答案,是使用了win的一个协议http://msdn.microsoft.com/en-us/library/aa767914(VS.85).aspx
这里比较详细
自己动手写了个demo(MFC不是很灵光先用C#winfrom了)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.Win32; //引用Microsoft.Win32命名空间详细说明MSDN
/*
* URL协议注册详细说明请见
* http://msdn.microsoft.com/en-us/library/aa767914(VS.85).aspx
*QQ664316183
*/
namespace URLProtocol
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
openFileDialog1.ShowDialog();
textBox2.Text = openFileDialog1.FileName;
}
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text != "" && textBox2.Text != "")
{
try
{
RegistryKey rgsk = Registry.ClassesRoot;//打开HKEY_CLASS_ROOT
if (rgsk.OpenSubKey(textBox1.Text) == null) //验证此键值是否存在
{
RegistryKey rgskroot = rgsk.CreateSubKey(textBox1.Text);
rgskroot.SetValue("", textBox1.Text + " Protocol");
rgskroot.SetValue("URL Protocol", textBox2.Text);
rgskroot.CreateSubKey("DefaultIcon").SetValue("", textBox2.Text + ",1");
rgskroot.CreateSubKey("shell").CreateSubKey("open").CreateSubKey("command").SetValue("", "/"" + textBox2.Text + "/" /"%1/"");
rgskroot.Close();
MessageBox.Show("协议创建成功!");
}
else MessageBox.Show("该协议已经存在!");
}
catch(Exception)
{
MessageBox.Show("注册表读取异常!");
}
}
else MessageBox.Show("协议名与处理程序不能为空!");
}
private void button3_Click(object sender, EventArgs e)
{
if (textBox3.Text != "")
{
try
{
RegistryKey rgsk = Registry.ClassesRoot;
if (rgsk.OpenSubKey(textBox3.Text) != null) //验证此键值是否存在
{
rgsk.DeleteSubKeyTree(textBox3.Text);
MessageBox.Show("协议卸载成功!");
}
else MessageBox.Show("协议不存在!");
rgsk.Close();
}
catch(Exception)
{
MessageBox.Show("注册表读取异常!");
}
}
else MessageBox.Show("卸载的协议名不能为空!");
}
}
}
注册协议
测试代码
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
</head>
<body>
<div>
<a href="helloworld://hello world">
<img border="0" src='http://is.qq.com/webpresence/images/status/01_online.gif' alt="点击这里给我发消息">
</a>
</div>
</body>
</html>
卸载协议
- URL Protocol应用
- URL Protocol- -(coolice)
- Data:url Protocol
- URL Protocol Handler
- 自定义URL Protocol 协议
- 自定义URL Protocol 协议
- Protocol基础知识及应用
- url应用
- Registering an Application to a URL Protocol
- URL Protocol Handler 的简单演示程序
- Registering an Application to a URL Protocol
- Registering an Application to a URL Protocol
- Registering an Application to a URL Protocol
- Registering an Application to a URL Protocol
- Registering an Application to a URL Protocol
- Registering an Application to a URL Protocol
- Registering an Application to a URL Protocol
- Registering an Application to a URL Protocol
- 个豆腐干反对
- Struts2中的文件上传
- 个人Java面试题收集
- 跨浏览器的iframe onload 事件监听
- excel 2003 列标题显示不全
- URL Protocol应用
- POJ 3278 : 经典BFS
- 我所知道的线程
- Discuz 7.2 分类信息试用心得,果然非常强大
- 支付宝接口需要特别注意的几点问题
- 解决FLASH在用硕思反编译后文件变的巨大的问题
- oracle存储过程中应用动态sql
- linux命令-top
- 使用AspJpeg组件为图片添加透明水印图片