Call local software through a link on the web page

Source: Internet
Author: User

The user puts forward a requirement that the locally installed C/S structure software should be called out.

Note: instead of clicking its shortcut or exe file, you need to call the software client by clicking a button or link on the webpage. I have found related information on the Internet and have two common solutions.

1. Use js Code for debugging. The Code is as follows:

[Javascript]
Function Run (strPath ){
Var objShell = new ActiveXObject ("wscript. shell ");
ObjShell. Run (strPath );
ObjShell = null;
}
 
<A onFocus = 'this. blur () 'title = "QQ" href = # onclick = javascript: Run ('file: // D:/Program % 20 Files/QQ/QQ.exe ', 'file')> call the QQ Program </a>
In this way, ActiveX script programs are used to control program calls. However, there is a security issue. You need to adjust the security level of the browser. In addition, you need to restrict the installation path of local software, which brings great trouble to the customer. If the customer's software is not installed in D:/Program % 20 Files/QQ path, the path cannot be found, which lacks flexibility and is not desirable.
2. Use a java program to write a panel, but it is difficult and the user experience is not good. The basic code is as follows:

[Java]
Public static void main (String [] args) throws Exception {
Process p = runtime.getruntime(cmd.exe c (
"\" C:/program files/<a href = "http://dev.21tx.com/ OS /windows/" target = "_ blank"> Windows </a>/notepad.exe \"");
P. waitFor ();
}
}

In this way, you can call the local bat program or exe program, which is also a security problem and path problem. There may be stability problems, and this method is not available.
In the end, it was achieved by a widget of longtu software company. The steps are as follows:

1. Install the control.

2. Add the <object> label and the code is as follows:

[Java]
<OBJECT
Classid = "clsid: A3E8EEE9-E85E-472A-AEB3-EB182A605C62"
Codebase = "/$ {res}/ocx/AppCallerXControl. ocx # version ="
Width = "0"
Height = "0"
Visible = "0"
Id = "AppCaller"
>
</OBJECT>

/$ {Res}/ocx/AppCallerXControl. ocx indicates the control path, id indicates the control object, and you can call methods in the control class.
[Java]
<Script LANGUAGE = "javascript">
Function clientInvoke (name, code ){
AppCaller. callApp (name, code );
}
</Script>
The clientInvoke function indicates the Click Event of a button or link. name is the identifier of the button or link and must be unique. Code is an additional parameter used to establish a connection with some fixed software and can be written at will.

3, and appears above the browser
Load activeX.

When you click the button or link, the Select box for selecting the exe program is displayed:

 

Find the exe program or shortcut (of course, other programs are also available, such as a static html page, bat program, and txt program, will execute its default open method ).

Note: Once a link is established with a software (or other), you do not need to re-select it after you click the link, because the link in the Registry has already been associated with the software path ,:

The preceding key values are unique, and the following data indicates the path of the software or file, so that the binding has been completed. To change the binding, delete the key in the registry, or change the key in the connection.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.