The following method registers the application in a URI scheme. This way you can use mycustproto: in your HTML code to run the local application. It works with Google Chrome version 51.0.2704.79 m (64-bit).
I mainly used this method to print a document without using the print dialog. The result is pretty good and is a seamless solution for integrating an external application with a browser.
HTML code (simple):
<a href="mycustproto:Hello World">Click Me</a>
HTML code (alternative):
<input id="DealerName" /> <button id="PrintBtn"></button> $('#PrintBtn').on('click', function(event){ event.preventDefault(); window.location.href = 'mycustproto:dealer ' + $('#DealerName').val(); });
The URI scheme will look like this:
You can create a URI scheme manually in the registry or run the file "mycustproto.reg" (see below).
HKEY_CURRENT_USER\Software\Classes mycustproto (Default) = "URL:MyCustProto Protocol" URL Protocol = "" DefaultIcon (Default) = "myprogram.exe,1" shell open command (Default) = "C:\Program Files\MyProgram\myprogram.exe" "%1"
example mycustproto.reg:
Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\Classes\mycustproto] "URL Protocol"="\"\"" @="\"URL:MyCustProto Protocol\"" [HKEY_CURRENT_USER\Software\Classes\mycustproto\DefaultIcon] @="\"mycustproto.exe,1\"" [HKEY_CURRENT_USER\Software\Classes\mycustproto\shell] [HKEY_CURRENT_USER\Software\Classes\mycustproto\shell\open] [HKEY_CURRENT_USER\Software\Classes\mycustproto\shell\open\command] @="\"C:\\Program Files\\MyProgram\\myprogram.exe\" \"%1\""
C # console application - myprogram.exe:
using System; using System.Collections.Generic; using System.Text; namespace myprogram { class Program { static string ProcessInput(string s) {
Try starting the program first to make sure the program is placed in the correct path:
cmd> "C:\Program Files\MyProgram\myprogram.exe" "mycustproto:Hello World"
Click the link on the HTML page:
The first time you see a warning popup.

In reset, configure the external protocol handler in Chrome:
If you have ever accepted the user protocol in Chrome and would like to set reset, do it (there is currently no interface in Chrome for changing the settings):
Change the " Local state " in this file along this path:
C:\Users\Username\AppData\Local\Google\Chrome\User Data\
or just follow the link:
%USERPROFILE%\AppData\Local\Google\Chrome\User Data\
Then search for this line: protocol_handler
You will see the user protocol there.
Note. . Close Google Chrome before editing the file. Otherwise, the change you make will be overwritten by Chrome.
Reference:
https://msdn.microsoft.com/en-us/library/aa767914(v=vs.85).aspx