当前位置: 代码迷 >> 综合 >> Windows 浏览器调起客户端应用程序
  详细解决方案

Windows 浏览器调起客户端应用程序

热度:11   发布时间:2023-10-31 14:02:11.0

1、添加注册表

方法一:新建文本文档,修改后缀未.reg复制以下内容进去
Windows Registry Editor Version 5.00[HKEY_CLASSES_ROOT\clientname]
@="clientname客户端"
"URL Protocol"=""[HKEY_CLASSES_ROOT\clientname\DefaultIcon]
@="C:\\Program Files (x86)\\bin\\a.exe,1"[HKEY_CLASSES_ROOT\clientname\Shell][HKEY_CLASSES_ROOT\clientname\Shell\Open][HKEY_CLASSES_ROOT\xsdp\Shell\Open\command]
@="\"C:\\Program Files (x86)\\bin\\a.exe\" \"%1\""其中,clientname为后续要访问的名称,应用路径为你自己程序的路径双击运行即可方法二:通过c#程序添加public static bool AddWebStart(string name, string path, bool hasParm){string parm = "", parm1 = "";if (hasParm){parm = ",1";parm1 = " \"%1\"";}try{RegistryKey regFather = Registry.ClassesRoot;RegistryKey myWebStart = regFather.CreateSubKey(name);myWebStart.SetValue("", name);myWebStart.SetValue("URL Protocol", "");RegistryKey myWebStartDefaultIcon = myWebStart.CreateSubKey("DefaultIcon");myWebStartDefaultIcon.SetValue("", path + parm);RegistryKey myWebStartShell = myWebStart.CreateSubKey("Shell");RegistryKey myWebStartShellOpen = myWebStartShell.CreateSubKey("Open");RegistryKey myWebStartShellOpenCommand = myWebStartShellOpen.CreateSubKey("Command");myWebStartShellOpenCommand.SetValue("", path + parm1);}catch(Exception e){Console.WriteLine(e.ToString());return false;}return true;}

2、新建个测试的html,查看结果

<html>
<head></head>
</body><a href="clientname://">打开clientname</a></body>
</html>

 

  相关解决方案