示例#1
0
        private static void setProgId()
        {
            using (RegistryKey key = Registry.LocalMachine.CreateSubKey(@"SOFTWARE\Classes\NexDirect.Url"))
            {
                key.SetValue("", "NexDirect http passthrough");

                string appLocation = WinTools.GetExecLocation();
                using (RegistryKey shellOpenKey = key.CreateSubKey(@"shell\open\command"))
                    shellOpenKey.SetValue("", $"\"{appLocation}\" \"/link:%1\"");
            }
        }
示例#2
0
        private void registerUriButton_Click(object sender, RoutedEventArgs e)
        {
            string appLocation = WinTools.GetExecLocation();

            try
            {
                // https://msdn.microsoft.com/en-AU/library/h5e7chcf.aspx
                using (RegistryKey key = Registry.CurrentUser.CreateSubKey(regUriSubKey))
                {
                    key.SetValue("", "NexDirect Handling Protocol"); // "" = (default)
                    key.SetValue("URL Protocol", "");

                    using (RegistryKey iconKey = key.CreateSubKey(@"DefaultIcon"))
                        iconKey.SetValue("", $"{appLocation},1");

                    using (RegistryKey shellOpenKey = key.CreateSubKey(@"shell\open\command"))
                        shellOpenKey.SetValue("", $"\"{appLocation}\" \"%1\"");
                }

                MessageBox.Show("The URI Scheme handler was registered successfully.");
            }
            catch (Exception ex) { MessageBox.Show($"An error occured whilst registering the handler...\n\n{ex.ToString()}"); }
        }
示例#3
0
        private static void registerCapabilities()
        {
            string appLocation = WinTools.GetExecLocation();

            using (RegistryKey key = Registry.LocalMachine.CreateSubKey(@"SOFTWARE\Clients\StartMenuInternet\NexDirect"))
            {
                key.SetValue("", "NexDirect");

                using (RegistryKey capibilitySubkey = key.CreateSubKey(@"Capabilities"))
                {
                    capibilitySubkey.SetValue("ApplicationDescription", "Intercepts browser requests so that relevant ones can be sent to NexDirect.");
                    capibilitySubkey.SetValue("ApplicationName", "NexDirect");

                    using (RegistryKey urlAssocKey = capibilitySubkey.CreateSubKey(@"URLAssociations"))
                    {
                        urlAssocKey.SetValue("http", "NexDirect.Url");
                        urlAssocKey.SetValue("https", "NexDirect.Url");
                    }
                }

                using (RegistryKey iconSubkey = key.CreateSubKey(@"DefaultIcon"))
                    iconSubkey.SetValue("", $"{appLocation},0");
            }
        }