Solved!!
I am trying to create a Custom URL Protocol of my application that will launch my application when they visit or clicked link to myapp:start
My problem is how to know where the user installed my application. Can the msi installer put the location when registering HKEY_CLASSES_ROOT to registry?
HKEY_CLASSES_ROOT
myapp
(Default) = "URL:myapp Protocol"
URL Protocol = ""
DefaultIcon
(Default) = "myapp.exe,1"
shell
open
command
(Default) = "C:\Program Files\MyAppFolder\MyApp.exe" "%1"
I wanted to change the path "C:\Program Files\MyAppFolder\MyApp.exe" to where the user installed my app during installation process.
Solution
HKEY_CLASSES_ROOT
myapp
(Default) = "URL:myapp Protocol"
URL Protocol = ""
DefaultIcon
(Default) = "myapp.exe,1"
shell
open
command
(Default) = "[TARGETDIR]MyApp.exe "%1""
[TARGETDIR] will automatically change to where the user installed the file e.g. "C:\Program Files\MyAppFolder\"
For more information click this link -> Registering an Application to a URI Scheme
The HKEY_CLASSES_ROOT (HKCR) key contains file name extension associations and COM class registration information such as ProgIDs, CLSIDs, and IIDs. It is primarily intended for compatibility with the registry in 16-bit Windows.
Start the registry editor (regedit.exe) Search for the name of the exe you want to remove from the "Open With" menu. If a match is found, and its root is HKEY_CLASSES_ROOT/xxx_auto_file then delete the tree HKEY_CLASSES_ROOT/xxx_auto_file.
HKEY_CLASSES_ROOT, often shortened as HKCR, is a registry hive in the Windows Registry and contains file extension association information, as well as a programmatic identifier (ProgID), Class ID (CLSID), and Interface ID (IID) data.
With the Visual Studio Setup Project, you can use the [TARGETDIR]
variable when creating your registry key.
This variable is automatically set to the target directory that your application is being installed into, simply append your .exe
file to the end.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With