Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How add value on hkey_classes_root key where the application installed

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

like image 315
Jeff Robert Dagala Avatar asked Mar 11 '13 10:03

Jeff Robert Dagala


People also ask

What does the key HKEY_CLASSES_ROOT contain?

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.

Can I delete HKEY_CLASSES_ROOT?

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.

What is Hkcr Clsid?

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.


1 Answers

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.

like image 99
Rudi Visser Avatar answered Sep 20 '22 13:09

Rudi Visser