Exemplo n.º 1
0
        /// <summary>
        /// Sets file associations in the registry.
        /// </summary>
        /// <param name="files">A list of all file types that should be associated with Stoffi.</param>
        private void SetAssociations(bool all)
        {
            var filetypes = new Stoffi.Associations().FullFileList;

            try
            {
                RegisterApplication(filetypes);
            }
            catch { }

            try
            {
                var type     = Type.GetTypeFromCLSID(Shell.CLSID_ApplicationAssociationRegistration);
                var typeUI   = Type.GetTypeFromCLSID(Shell.CLSID_ApplicationAssociationRegistrationUI);
                var comobj   = Activator.CreateInstance(type);
                var comobjUI = Activator.CreateInstance(typeUI);
                var reg      = (Shell.IApplicationAssociationRegistration)comobj;
                var regUI    = (Shell.IApplicationAssociationRegistrationUI)comobjUI;

                if (all && reg != null)
                {
                    reg.SetAppAsDefaultAll("Stoffi");
                }
                else if (regUI != null)
                {
                    regUI.LaunchAdvancedAssociationUI("Stoffi");
                }
                Shell.SHChangeNotify(Shell.SHCNE_ASSOCCHANGED, Shell.SHCNF_IDLIST, IntPtr.Zero, IntPtr.Zero);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Clean up the filesystem and registry from traces of Stoffi.
        /// </summary>
        private void Uninstall()
        {
            try
            {
                var filetypes = new Stoffi.Associations().FullFileList;
                UnregisterApplication(filetypes);
            }
            catch (Exception e) { MessageBox.Show(e.Message); }
            try
            {
                File.Delete(U.LogFile);
            }
            catch { }

            try
            {
                var folder = Path.GetDirectoryName(U.FullPath);
                //Directory.Delete(folder, true);
            }
            catch { }

            try
            {
                var config       = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
                var configFolder = new DirectoryInfo(config.FilePath).Parent.Parent.FullName;
                //Directory.Delete(configFolder, true);
            }
            catch { }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Clean up the filesystem and registry from traces of Stoffi.
        /// </summary>
        private void Uninstall()
        {
            try
            {
                var filetypes = new Stoffi.Associations().FullFileList;
                UnregisterApplication(filetypes);
            }
            catch (Exception e) { MessageBox.Show(e.Message); }
            try
            {
                File.Delete(U.LogFile);
            }
            catch { }

            try
            {
                var folder = Path.GetDirectoryName(U.FullPath);
                //Directory.Delete(folder, true);
            }
            catch { }

            try
            {
                var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
                var configFolder = new DirectoryInfo(config.FilePath).Parent.Parent.FullName;
                //Directory.Delete(configFolder, true);
            }
            catch { }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Sets file associations in the registry.
        /// </summary>
        /// <param name="files">A list of all file types that should be associated with Stoffi.</param>
        private void SetAssociations(bool all)
        {
            var filetypes = new Stoffi.Associations().FullFileList;
            try
            {
                RegisterApplication(filetypes);
            }
            catch { }

            try
            {
                var type = Type.GetTypeFromCLSID(Shell.CLSID_ApplicationAssociationRegistration);
                var typeUI = Type.GetTypeFromCLSID(Shell.CLSID_ApplicationAssociationRegistrationUI);
                var comobj = Activator.CreateInstance(type);
                var comobjUI = Activator.CreateInstance(typeUI);
                var reg = (Shell.IApplicationAssociationRegistration)comobj;
                var regUI = (Shell.IApplicationAssociationRegistrationUI)comobjUI;

                if (all && reg != null)
                    reg.SetAppAsDefaultAll("Stoffi");
                else if (regUI != null)
                    regUI.LaunchAdvancedAssociationUI("Stoffi");
                Shell.SHChangeNotify(Shell.SHCNE_ASSOCCHANGED, Shell.SHCNF_IDLIST, IntPtr.Zero, IntPtr.Zero);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }