zoukankan      html  css  js  c++  java
  • js调用本地程序

    前几天,做项目时候用到js调用本地的程序,找了好多资料,一种是写入注册表,一种是写一个浏览器插件,相对来说,写一个注册表更简单一点,因为需求很紧。下面就是我的总结,希望可以对你们有所帮助,具体从哪里找的忘了,如果也有看见的烦劳烦告知一下,不胜感激。

    第一步:

    写入注册表,注册表示例

    Windows Registry Editor Version 5.00  
    
    [HKEY_CLASSES_ROOTopenNotepad]  
    
    @="URL:openNotepad Protocol"  
    
    "URL Protocol"=""  
    
    [HKEY_CLASSES_ROOTopenNotepadDefaultIcon]  
    
    @="TestKZT.exe,1"  
    
    [HKEY_CLASSES_ROOTopenNotepadshell]  
    
    [HKEY_CLASSES_ROOTopenNotepadshellopen]  
    
    [HKEY_CLASSES_ROOTopenNotepadshellopencommand]  
    
    @="cmd /c set m=%1 & call set m=%%m:openNotepad:=%% & call "C:\Windows\TestKZT.exe" %%m%% & exit"  

    保存为1.reg,运行就好

    第二步,用浏览器调用并传入参数,示例

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
          <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      </head>
        <body>
            <div>
            <a href="openNotepad:www.baidu.com">百度</a>  
            </div>
        </body>
    </html>

    即可调用外部程序

    其他注释:

    示例调用的是C:\Windows\TestKZT.exe的自定义程序,其他类似,传入参数方式相似

    这个就不需要什么小例子了,如有需要,留下邮箱。

  • 相关阅读:
    tableView的高度问题
    信任机型
    cell 内部 设置width 总不对
    图文混排
    UICollectionview实现自定义cell的移动删除
    ios 各种技术
    打包ane之后在FB上生成ipa的阶段错误
    自动布局出代码植入 的图像化实例
    MapReduce编程实例
    二叉树的遍历(递归遍历、非递归遍历、层序遍历)
  • 原文地址:https://www.cnblogs.com/itljf/p/5859435.html
Copyright © 2011-2022 走看看