首先注册服务

方法1,保存为reg文件直接执行,需要按需修改路径

 Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\EasyPrint]
"URL Protocol"="C:\\Program Files\\EasyPrint\\EasyPrint.exe"
@="EasyPrintProtocol"
[HKEY_CLASSES_ROOT\EasyPrint\DefaultIcon]
@="C:\\Program Files\\EasyPrint\\EasyPrint.exe,1"
[HKEY_CLASSES_ROOT\EasyPrint\shell]
[HKEY_CLASSES_ROOT\EasyPrint\shell\open]
[HKEY_CLASSES_ROOT\EasyPrint\shell\open\command]
@="\"C:\\Program Files\\EasyPrint\\EasyPrint.exe\" \"%1\""

方法2,在程序中自动注册服务,此操作可以放到安装程序中,根据实际情况获取path即可

var path = "E:\\code\\EasyPrint\\EasyPrint\\bin\\Debug";
List<string> cmds =
new List<string>{
"/c" + $"reg add \"HKCR\\EasyPrint\" /f /ve /d \"EasyPrintProtocol\"",
"/c" + $"reg add \"HKCR\\EasyPrint\" /f /v \"URL Protocol\" /d \"",
"/c" + $"reg add \"HKCR\\EasyPrint\\DefaultIcon\" /f /ve /d \""+path+"\\EasyPrint.exe,1\"",
"/c" + $"reg add \"HKCR\\EasyPrint\\shell\\open\\command\" /f /ve /d \"\\\""+path+"\\EasyPrint.exe\\\" \\\"%1\\\"\""
};
foreach (var command in cmds)
{
Process p = new Process
{
StartInfo =
{
FileName = "cmd.exe",
Arguments = command,
UseShellExecute = false,
RedirectStandardInput = true,
RedirectStandardOutput = true,
CreateNoWindow = true
}
};
p.Start();
p.StandardInput.WriteLine("exit");
p.Close();
}

将会在系统中注册一个协议,此协议名称根据注册表的key决定,此处为EasyPrint,大小写无关

调用时即使用  EasyPrint://par1&par2

具体参数传递方式根据需要自行处理即可,系统会将完整请求自动转发给注册的程序

最新文章

  1. web学习之servlet
  2. rsync无密码实时增量同步
  3. python中split函数的使用
  4. nancy的诊断2
  5. android113 自定义进度条
  6. 访问Tableau自带的PostgreSQL数据库
  7. 使用 Cordova+Visual Studio 创建跨平台移动应用(2)
  8. $.extend()方法和(function($){...})(jQuery)详解
  9. [Codeforces 100633J]Ceizenpok’s formula
  10. TensorRT&amp;Sample&amp;Python[end_to_end_tensorflow_mnist]
  11. [COCI2015]COCI
  12. ubuntu打开windows下txt文档乱码问题的解决
  13. Hadoop HBase概念学习系列之HBase里的Zookeeper(二十一)
  14. REST构架风格介绍之一:状态表述转移
  15. Android模仿三星手机系统滑动条滑动时滑块变大的特效
  16. Javscript调用iframe框架页面中函数的方法
  17. burn android images with fastboot
  18. Android 布局学习之——LinearLayout的layout_weight属性
  19. 使用animate()完成修改图片src切换图片的动画效果
  20. 面向对象先修:Java入门

热门文章

  1. functools:管理函数的工具
  2. python基础编程: 编码补充、文件操作、集合、函数参数、函数递归、二分查找、匿名函数与高阶函数
  3. PAT乙级1013
  4. PHP底层运行机制与原理
  5. TCP协议(包括TCP的连接过程,数据分段,TCP有关服务器优化)
  6. 数据管理必看!Kendo UI for jQuery过滤器状态保持
  7. 用脚本来运行scrapy crawl ...
  8. Mybatis的@UpdateProvider注解的使用(转)
  9. numpy常用矩阵操作
  10. 题解 【POJ1722】 SUBTRACT