1 Web打开winform程序,需要使用的标签为a标签
<a href="SelfName://">连接提示</a> //SelfName 是自己的自定义协议
2 Winform程序一般不需要做任何操作,如果需要参数传递的情况下,可以将Winform的Program.cs程序修改一下,用以接收参数
static class Program{/// <summary>/// 应用程序的主入口点。/// </summary>//[STAThread]//static void Main()//{// Application.EnableVisualStyles();// Application.SetCompatibleTextRenderingDefault(false);// Application.Run(new Form1());//}/// <summary>/// 应用程序的主入口点。/// </summary>[STAThread]static void Main(String[] args){try{Application.EnableVisualStyles();Application.SetCompatibleTextRenderingDefault(false);//SplashScreen.Splasher.Show(typeof(SplashScreen.frmSplash));if (args.Length > 0){args[0] = args[0].Replace("SelfName://", "");}var form = new Form1(args);Application.Run(form);}catch (Exception ex){}}}
3 最重要的是进行注册表注册
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\SelfName]
@="SelfNameProtocol"
"URL Protocol"="C:\\Tmp\\Winform\\Winform.exe"
[HKEY_CLASSES_ROOT\SelfName\DefaultIcon]
@="C:\\Tmp\\Winform\\Winform.exe,0"
[HKEY_CLASSES_ROOT\SelfName\shell]
[HKEY_CLASSES_ROOT\SelfName\shell\open]
[HKEY_CLASSES_ROOT\SelfName\shell\open\command]
@="\"C:\\Tmp\\Winform\\Winform.exe\" \"%0\""
这里面SelfName是可以自定义的,这里面有一个参数0,查看其他人的博客都是1,个人感觉可能与传输参数个数有关,这个理解仍需验证,先记录到这里。