locked
Registering this on HKey programatically RRS feed

  • Question

  • hello,

    how can i register something like this programatically?

    [HKEY_CLASSES_ROOT]

      [runapp]

         (Default) = "URL:RunApp Protocol Handler"

         URL Protocol = ""

         [DefaultIcon]

           (Default) = "c:\whatever\RunAppUrlProtocol.exe”

         [shell]

           [open]

              [command]

                (Default) = "c:\whatever\RunAppUrlProtocol.exe "%1""



    Thank you.
    Friday, September 12, 2008 12:03 AM

Answers

  •  hi,

    To register these items, you can use Registry.SetValue. 

     string str = "HKEY_CLASSES_ROOT\\runapp";
                    Registry.SetValue(str, "", "URL:RunApp Protocol", RegistryValueKind.String);
                    Registry.SetValue(str, "URL Protocol", "", RegistryValueKind.String);
                    Registry.SetValue(str + "\\DefaultIcon", "", "VSSProtocolHandler.exe", RegistryValueKind.String);
                    Registry.SetValue(str+"file://\\shell\\open\\command \"%1\"",RegistryValueKind.String);

    best regards,

    harry
    • Proposed as answer by Harry Zhu Thursday, September 18, 2008 1:43 AM
    • Marked as answer by jack 321 Monday, September 22, 2008 2:00 AM
    Monday, September 15, 2008 10:28 AM

All replies

  • im doing Hkey protocols... thanks

    ref: http://blogs.msdn.com/noahc/archive/2006/10/19/register-a-custom-url-protocol-handler.aspx
    Friday, September 12, 2008 12:36 AM
  • help!
    Friday, September 12, 2008 5:58 AM
  •  hi,

    To register these items, you can use Registry.SetValue. 

     string str = "HKEY_CLASSES_ROOT\\runapp";
                    Registry.SetValue(str, "", "URL:RunApp Protocol", RegistryValueKind.String);
                    Registry.SetValue(str, "URL Protocol", "", RegistryValueKind.String);
                    Registry.SetValue(str + "\\DefaultIcon", "", "VSSProtocolHandler.exe", RegistryValueKind.String);
                    Registry.SetValue(str+"file://\\shell\\open\\command \"%1\"",RegistryValueKind.String);

    best regards,

    harry
    • Proposed as answer by Harry Zhu Thursday, September 18, 2008 1:43 AM
    • Marked as answer by jack 321 Monday, September 22, 2008 2:00 AM
    Monday, September 15, 2008 10:28 AM
  • Sadly it seems like your example is incomplete. I am getting an error message about your last line of code regarding the arguments to SetValue.

    Error 1 No overload for method 'SetValue' takes 2 arguments

    I would attempt to fix this error by miself but I have bare experience with c# at most.

    I, however, do wish to thank you for your code.

    Monday, May 27, 2013 9:24 AM