Jelly House acridine original content: without permission forbidden reprint ~
How to use the Web page to adjust the client program like Baidu Cloud?
First of all, my experience, stupid I directly with the C#CS program to adjust the method of the local program, written on the Web page, obviously, this is wrong, so that the server is tuned up the program, not the client program.
So, what exactly is the operation?
The code has a lot of shortcomings, there will certainly be a better way, if you have any suggestions, please contact me qq:1772829123 or comments. Please do not hesitate to enlighten the big boys!
The code of the webpage is quite simple,
MYAPP: Is the program to be tuned, you need to add the registry information
Aadmin,123321 is a passed argument that is actually passed through a string, and the parameter that is received after the program is opened is "myapp:aadmin,123321".
This I do not know how to deal with, direct array way to pass, if the Tao friends know, want to guide!
The main change is the registry information.
<inputtype= "button"value= "Open My App"onclick= "Openmyapp ()"/><Script> functionOpenmyapp () {window.location.href='myapp:aadmin,123321'; }</Script>
Registry modification requires a file to increase the registry information of the program, or it cannot be adjusted. Here is an added, one deleted.
Increased by:
5.00 [HKEY_CLASSES_ROOT\myapp]@="MyApp""URL Protocol" = "Your Software path" [HKEY_CLASSES_ROOT\myapp\defaulticon]@="Your software path , 1"[HKEY_CLASSES_ROOT \myapp\shell][hkey_classes_root\myapp\shell\open][hkey_classes_root\myapp\shell\ open\command]@="\" software path \ "\"%1\ ""
deleted by:
5.00 [-hkey_classes_root\myapp]
In this way, the registry information is modified, but the actual program does not exist is not called up OH
The code for the program is this:
The first step is to modify the application's main entry point, which is Program.cs
Static voidMain (string[] args) {application.enablevisualstyles (); Application.setcompatibletextrenderingdefault (false); stringstr =string. Empty; if(args. Length >0) {str= args[0]. ToString (); Application.Run (NewForm1 (str)); } Application.Run (NewForm1 ()); }
Gets the value that the page passed through by receiving parameters.
Constructors for overloading Form1
Public Partial classForm1:form { Public stringUserName =string. Empty; Public stringUserpwd =string. Empty; PublicForm1 () {InitializeComponent (); } PublicForm1 (stringstr) {STR= str. Replace ("MyApp:",""); string[] args = str. Split (','); if(args. length>=2) {UserName= args[0]. ToString (); Userpwd= args[1]. ToString (); } InitializeComponent (); } Private voidForm1_Load (Objectsender, EventArgs e) { This. txtUsername.Text =UserName; This. Txtuserpwd.text =userpwd; } }
Notice here that MyApp will all be lowercase when the arguments are passed in.
Finally, look at the effect of the operation:
Select Open, you will see the user name and password automatically fill in, just testing, interface details please ignore ~
To tune up the client program from the Web page