Reputation: 9
The correct method is to register your custom URL Protocol in windows registry as follows:
Once the above keys and values are added, from the web page, just call "customurl:\parameter1=xxx¶meter2=xxx" . You will receive the entire url as the argument in exe, which you need to process inside your exe. Change 'customurl' with the text of your choice.
Not sure how this works, i am getting lost somewhere, can someone help me with this with an example of an app? Thanks in advance!
Upvotes: 0
Views: 2307
Reputation: 101756
You are on the right track, you just need to change the "ExeName.exe" part to the path of your .exe. Your .exe application needs to parse the command line, this is where the URL is.
Here is a example batch file that implements a protocol handler:
@echo off
setlocal ENABLEEXTENSIONS DISABLEDELAYEDEXPANSION
if not "%~1."=="." goto proto
choice /C IUE /M "Install? Uninstall? Example launch?"
if errorlevel 3 goto launch
if errorlevel 2 goto uninstall
if errorlevel 1 goto install
goto :EOF
:proto
echo Launched protocol with %*
pause
goto :EOF
:install
reg add "HKCU\Software\Classes\customUrl" /ve /d "customUrl handler" /f
reg add "HKCU\Software\Classes\customUrl" /v "URL Protocol" /f
reg add "HKCU\Software\Classes\customUrl\shell\open\command" /ve /d """"%~0""" %%1" /f
pause
goto :EOF
:uninstall
reg delete "HKCU\Software\Classes\customUrl" /f
pause
goto :EOF
:launch
start "" "customUrl:foo=bar"
goto :EOF
Save as myproto.cmd and run it and press i
to install it. Then run it again and press e
to launch a URL or make a dummy .html file with a customUrl: link you can click on.
Upvotes: 1