Пример #1
0
        private static void RegisterForActivation()
        {
            // Register one or more supported filetypes,
            // an icon (specified by binary file path plus resource index),
            // a display name to use in Shell and Settings,
            // zero or more verbs for the File Explorer context menu,
            // and the path to the EXE to register for activation.
            string[] myFileTypes = { ".foo", ".foo2", ".foo3" };
            string[] verbs       = { "view", "edit" };
            ActivationRegistrationManager.RegisterForFileTypeActivation(
                myFileTypes,
                executablePathAndIconIndex,
                "Contoso File Types",
                verbs,
                executablePath
                );

            // Register a URI scheme for protocol activation,
            // specifying the scheme name, icon, display name and EXE path.
            ActivationRegistrationManager.RegisterForProtocolActivation(
                "foo",
                executablePathAndIconIndex,
                "Contoso Foo Protocol",
                executablePath
                );

            // Register for startup activation.
            ActivationRegistrationManager.RegisterForStartupActivation(
                "ContosoStartupId",
                executablePath
                );

            OutputMessage("Registered for rich activation");
        }
        private void UnregisterButton_Click(object sender, RoutedEventArgs e)
        {
            OutputMessage("Unregistering for rich activation");

            // Unregister one or more registered filetypes.
            try
            {
                string[] myFileTypes = { ".foo", ".foo2", ".foo3" };
                ActivationRegistrationManager.UnregisterForFileTypeActivation(
                    myFileTypes,
                    executablePath
                );
            }
            catch (Exception ex)
            {
                OutputMessage($"Error unregistering file types {ex.Message}");
            }

            // Unregister a protocol scheme.
            ActivationRegistrationManager.UnregisterForProtocolActivation(
                "foo",
                "");

            // Unregister for startup activation.
            ActivationRegistrationManager.UnregisterForStartupActivation(
                "ContosoStartupId");
        }
Пример #3
0
        private void UnregisterForRichActivation()
        {
            // Unregister one or more registered filetypes.
            try
            {
                string[] myFileTypes = { ".foo", ".foo2", ".foo3" };
                ActivationRegistrationManager.UnregisterForFileTypeActivation(
                    myFileTypes,
                    executablePath
                    );
            }
            catch (Exception ex)
            {
                OutputMessage($"Error unregistering file types {ex.Message}");
            }

            // Unregister a protocol scheme.
            ActivationRegistrationManager.UnregisterForProtocolActivation(
                "foo",
                "");

            // Unregister for startup activation.
            ActivationRegistrationManager.UnregisterForStartupActivation(
                "ContosoStartupId");
        }
Пример #4
0
 public static void UnregisterForFileActivation()
 {
     // Unregister one or more registered filetypes.
     try
     {
         string[] myFileTypes = { ".moo" };
         ActivationRegistrationManager.UnregisterForFileTypeActivation(
             myFileTypes,
             executablePath
             );
     }
     catch (Exception ex)
     {
         ReportInfo($"Error unregistering file types {ex.Message}");
     }
 }
Пример #5
0
 public static void RegisterForFileActivation()
 {
     // Register one or more supported filetypes,
     // an icon (specified by binary file path plus resource index),
     // a display name to use in Shell and Settings,
     // zero or more verbs for the File Explorer context menu,
     // and the path to the EXE to register for activation.
     string[] myFileTypes = { ".moo" };
     string[] verbs       = { "view", "edit" };
     ActivationRegistrationManager.RegisterForFileTypeActivation(
         myFileTypes,
         executablePathAndIconIndex,
         "Contoso File Types",
         verbs,
         executablePath
         );
 }
Пример #6
0
        private static void UnregisterForActivation()
        {
            // BUG Unregistering a filetype removes the
            // [HKEY_CURRENT_USER\Software\Classes\App.5761a1850f7033ad.File]
            // entry, and the value under [HKEY_CURRENT_USER\Software\Classes\.foo\OpenWithProgids]
            // but not the [HKEY_CURRENT_USER\Software\Classes\.foo] key.

            // Unregister one or more registered filetypes.
            try
            {
                string[] myFileTypes = { ".foo", ".foo2", ".foo3" };
                ActivationRegistrationManager.UnregisterForFileTypeActivation(
                    myFileTypes,
                    executablePath
                    );
            }
            catch (Exception ex)
            {
                OutputMessage($"Error unregistering file types {ex.Message}");
            }

            // BUG Unregistering a protocol removes the
            // [HKEY_CURRENT_USER\Software\Classes\App.5761a1850f7033ad.Protocol]
            // entry, but not the [HKEY_CURRENT_USER\Software\Classes\foo] key.

            // Unregister a protocol scheme.
            ActivationRegistrationManager.UnregisterForProtocolActivation(
                "foo",
                "");

            // Unregister for startup activation.
            ActivationRegistrationManager.UnregisterForStartupActivation(
                "ContosoStartupId");

            OutputMessage("Unregistered for rich activation");
        }