Beispiel #1
0
        internal static void Install(string location)
        {
            try
            {
                System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
                FileVersionInfo            fvi      = FileVersionInfo.GetVersionInfo(assembly.Location);
                string version = fvi.FileVersion;

                Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\xMenuTools");
                File.WriteAllText(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\xMenuTools\\Version.txt", version);

                RegistryKey xMenuToolsSettings = Registry.CurrentUser.CreateSubKey("SOFTWARE\\xMenuTools\\Settings");
                RegistryKey InstallInfo        = null;
                if (ArchitectureCheck.ProcessorIs64Bit())
                {
                    RegistryKey RegUninstallKey64 = Registry.LocalMachine.CreateSubKey(Resources.RegUninstallKey64String);
                    InstallInfo = RegUninstallKey64;
                }
                if (!ArchitectureCheck.ProcessorIs64Bit())
                {
                    RegistryKey RegUninstallKey32 = Registry.LocalMachine.CreateSubKey(Resources.RegUninstallKey32String);
                    InstallInfo = RegUninstallKey32;
                }
                StartProcess.StartInfo(@"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\RegAsm.exe", "\"" + location + "\\xMenuTools.dll" + "\"" + " -codebase", true, true, true);

                // Adds Information to Uninstall - Change to 32 bit for compiling x86
                InstallInfo.SetValue("InstallLocation", "\"" + location + "\"", RegistryValueKind.String);
                InstallInfo.SetValue("InstallFileLocation", "\"" + location + @"\xMenuTools.exe" + "\"", RegistryValueKind.String);
                InstallInfo.SetValue("UninstallString", "\"" + location + @"\xMenuTools.exe" + "\"" + " -uninstall", RegistryValueKind.String);
                InstallInfo.SetValue("DisplayIcon", location + @"\xMenuTools.exe", RegistryValueKind.String);
                InstallInfo.SetValue("Publisher", "xCONFLiCTiONx", RegistryValueKind.String);
                InstallInfo.SetValue("HelpLink", website, RegistryValueKind.String);
                InstallInfo.SetValue("DisplayName", Resources.xMenuTools, RegistryValueKind.String);
                InstallInfo.SetValue("DisplayVersion", GetAssembly.AssemblyInformation("version"), RegistryValueKind.String);
                /* User Settings */

                SetRegistryItems.SetItems();

                // Create Shorcut in All Users Start Menu Programs
                StringBuilder allUserProfile = new StringBuilder(260);
                NativeMethods.SHGetSpecialFolderPath(IntPtr.Zero, allUserProfile, NativeMethods.CSIDL_COMMON_STARTMENU, false);

                string programs_path = Path.Combine(allUserProfile.ToString(), "Programs");

                string shortcutFolder = Path.Combine(programs_path, @"xMenuTools");
                if (!Directory.Exists(shortcutFolder))
                {
                    Directory.CreateDirectory(shortcutFolder);
                }

                using (new Settings())
                {
                    new Settings().ShowDialog();
                }

                Shortcut.Create(shortcutFolder, InstallInfo.ToString());

                Environment.Exit(0);
            }
            catch (Exception ex)
            {
                MessageForm(ex.Message + Environment.NewLine + ex.StackTrace, Resources.xMenuTools, MessageBoxButtons.OK, MessageBoxIcon.Error);
                Environment.Exit(0);
            }
        }
Beispiel #2
0
        private void GetSettings()
        {
            try
            {
                if (key != null)
                {
                    OpenNotepadFiles           = key.GetValue("OpenNotepadFiles");
                    BlockWithFirewallFiles     = key.GetValue("BlockWithFirewallFiles");
                    CopyNameFiles              = key.GetValue("CopyNameFiles");
                    CopyPathFiles              = key.GetValue("CopyPathFiles");
                    CopyURLFiles               = key.GetValue("CopyURLFiles");
                    CopyLongPathFiles          = key.GetValue("CopyLongPathFiles");
                    AttributesFiles            = key.GetValue("AttributesFiles");
                    SymlinkFiles               = key.GetValue("SymlinkFiles");
                    TakeOwnershipFiles         = key.GetValue("TakeOwnershipFiles");
                    AttributesShort            = key.GetValue("AttributesShort");
                    OpenNotepadShort           = key.GetValue("OpenNotepadShort");
                    SystemFoldersDirectoryBack = key.GetValue("SystemFoldersDirectoryBack");
                    CopyNameShortFiles         = key.GetValue("CopyNameShortFiles");
                    CopyPathShortFiles         = key.GetValue("CopyPathShortFiles");
                    CopyURLShortFiles          = key.GetValue("CopyURLShortFiles");
                    CopyLongPathShortFiles     = key.GetValue("CopyLongPathShortFiles");
                    PasteContentsDirectoryBack = key.GetValue("PasteContentsDirectoryBack");

                    if (OpenNotepadFiles != null)
                    {
                        if (OpenNotepadFiles.ToString() == "1")
                        {
                            NotepadCheckBox.Checked = true;
                        }
                    }
                    if (BlockWithFirewallFiles != null)
                    {
                        if (BlockWithFirewallFiles.ToString() == "1")
                        {
                            BlockWithFirewallCheckBox.Checked = true;
                        }
                    }
                    if (CopyNameFiles != null)
                    {
                        if (CopyNameFiles.ToString() == "1")
                        {
                            CopyFileNameCheckBox.Checked = true;
                        }
                    }
                    if (CopyPathFiles != null)
                    {
                        if (CopyPathFiles.ToString() == "1")
                        {
                            CopyFilePathCheckBox.Checked = true;
                        }
                    }
                    if (CopyURLFiles != null)
                    {
                        if (CopyURLFiles.ToString() == "1")
                        {
                            CopyURLFilesCheckBox.Checked = true;
                        }
                    }
                    if (CopyLongPathFiles != null)
                    {
                        if (CopyLongPathFiles.ToString() == "1")
                        {
                            CopyLongPathFilesCheckBox.Checked = true;
                        }
                    }
                    if (AttributesFiles != null)
                    {
                        if (AttributesFiles.ToString() == "1")
                        {
                            FileAttributesCheckBox.Checked = true;
                        }
                    }
                    if (SymlinkFiles != null)
                    {
                        if (SymlinkFiles.ToString() == "1")
                        {
                            FileSymLinkCheckBox.Checked = true;
                        }
                    }
                    if (TakeOwnershipFiles != null)
                    {
                        if (TakeOwnershipFiles.ToString() == "1")
                        {
                            TakeOwnershipFileCheckBox.Checked = true;
                        }
                    }
                    if (AttributesShort != null)
                    {
                        if (AttributesShort.ToString() == "1")
                        {
                            AttributesShortCheckbox.Checked = true;
                        }
                    }
                    if (OpenNotepadShort != null)
                    {
                        if (OpenNotepadShort.ToString() == "1")
                        {
                            ShortNotepadCheckbox.Checked = true;
                        }
                    }
                    if (CopyNameShortFiles != null)
                    {
                        if (CopyNameShortFiles.ToString() == "1")
                        {
                            CopyNameShortCheckbox.Checked = true;
                        }
                    }
                    if (CopyPathShortFiles != null)
                    {
                        if (CopyPathShortFiles.ToString() == "1")
                        {
                            CopyPathShortCheckbox.Checked = true;
                        }
                    }
                    if (CopyURLShortFiles != null)
                    {
                        if (CopyURLShortFiles.ToString() == "1")
                        {
                            CopyURLShortCheckbox.Checked = true;
                        }
                    }
                    if (CopyLongPathShortFiles != null)
                    {
                        if (CopyLongPathShortFiles.ToString() == "1")
                        {
                            CopyLongPathShortCheckbox.Checked = true;
                        }
                    }
                    GetSettingsFinal(key);
                }
                else
                {
                    SetRegistryItems.SetItems();
                }
            }
            catch (Win32Exception ex)
            {
                MessageForm(ex.Message + Environment.NewLine + ex.StackTrace + Environment.NewLine + ex.Source + Environment.NewLine + ex.GetBaseException() + Environment.NewLine + ex.TargetSite, "xMenuTools", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }