zoukankan      html  css  js  c++  java
  • 使用网页打开本地exe

    方案一 : 

    通过IE浏览器自带的ActiveX控件打开

    <!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" xml:lang="zh-cn">
    <head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    <title>open exe</title>
    <script type="text/javascript">
        function run(strPath){
            var objShell = new ActiveXObject("wscript.shell");
            objShell.Run(strPath);
            objShell = null;
        }
        //注意路径中必须使用/ ,而不能使用
        function open(){
            run("D:/qbsoft/QBRecords.exe");
        }
    </script>
    </head>
    <body>
    <a href="javascript:open()">open&nbsp;exe</a>
    </body>
    </html>

    方案二:

    创建QBRecord.reg (编码为unicode)

    Windows Registry Editor Version 5.00

    [HKEY_CLASSES_ROOTQBRecords]
    @="URL:QBRecords"
    "URL Protocol"=""

    [HKEY_CLASSES_ROOTQBRecordsDefaultIcon]
    @="D:\qbsoft\QBRecords.exe"

    [HKEY_CLASSES_ROOTQBRecordsshell]

    [HKEY_CLASSES_ROOTQBRecordsshellopen]

    [HKEY_CLASSES_ROOTQBRecordsshellopencommand]
    @=""D:\qbsoft\QBRecords.exe" "

    注:

        若需向exe传递参数,可以直接传递也可以用中间文件将注册表传入的参数进行转换 ,

    [HKEY_CLASSES_ROOTQBRecordsshellopencommand]
    @=""D:\qbsoft\QBRecords.bat" "%1" "

    [HKEY_CLASSES_ROOTQBRecordsshellopencommand]
    @=""D:\qbsoft\QBRecords.exe" "%1" "

    其中 QBRecords.bat 内容示例如下

    call QBRecord.exe -devextensions -command -username=%1 -password=mangaer -Xms512m -Xmn512m -Xmx1024m
    pause

    网页调用

    <a href="QBRecords://">open&nbsp;reg</a>
  • 相关阅读:
    137. Single Number II (Bit)
    136. Single Number (Bit)
    89. Gray Code (Bit)
    57. Insert Interval (Array; Sort)
    56. Merge Intervals (Array; Sort)
    UNIX 网络编程笔记-CH3:套接字编程简介
    UNIX 网络编程笔记-CH2:TCP、UDP概貌
    TSP-旅行商问题
    Java 集合:迭代器(Iterator, Iterable)
    PAT 1029. Median
  • 原文地址:https://www.cnblogs.com/hi-gdl/p/13207238.html
Copyright © 2011-2022 走看看