Пример #1
0
        private void OnEditClick(object sender, EventArgs e)
        {
            // Valid registry?
            if (workKey == null)
            {
                MessageBox.Show("No registry in this package");
                return;
            }

            // Require elevation
            if (!requireElevation())
            {
                return;
            }

            // Notification window
            PackageBuiltNotify packageBuiltNotify = new PackageBuiltNotify();
            String             friendlyKeyName    = System.IO.Path.GetFileName(System.IO.Path.GetDirectoryName(workKey.Name));

            packageBuiltNotify.Do("Registry editor will now open. Please edit entries under the key '" +
                                  friendlyKeyName + "'. Once you close the registry editor, your changes will be applied.",
                                  "", "", "RegeditExplain");

            // Set LastKey to the work key
            RegistryKey regKey;

            try
            {
                regKey = Registry.CurrentUser.CreateSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Regedit");
                regKey.SetValue("LastKey", "Computer\\" + workKey.Name);
                regKey.Close();
            }
            catch
            {
                return;
            }

            // Run RegEdit
            System.Diagnostics.ProcessStartInfo procStartInfo =
                new System.Diagnostics.ProcessStartInfo("Regedit.exe", "-m");
            System.Diagnostics.Process proc = new System.Diagnostics.Process();
            procStartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Maximized;
            proc.StartInfo            = procStartInfo;
            try
            {
                proc.Start();
                proc.WaitForExit();
                OnPackageOpenUI();
                virtPackage.SaveRegWorkKey();
                dirty = true;
            }
            catch
            {
                // Exception will occur if user refuses UAC elevation for example..
            }
        }
Пример #2
0
        public MainForm(string packageExeFile, bool notifyPackageBuilt)
        {
            InitializeComponent();
            dragging = false;

            // helpVirtMode
            SplitTextHelp(propertyVirtModeRam, out helpVirtModeRam);
            SplitTextHelp(propertyVirtModeDisk, out helpVirtModeDisk);

            // helpIsolationMode
            SplitTextHelp(propertyIsolationDataMode, out helpIsolationModeData);
            SplitTextHelp(propertyIsolationIsolated, out helpIsolationModeIsolated);
            SplitTextHelp(propertyIsolationMerge, out helpIsolationModeFull);

            // panelWelcome
            panelWelcome.Parent = this;
            panelWelcome.BringToFront();
            panelWelcome.Dock = DockStyle.None;
            panelWelcome.Dock = DockStyle.Fill;
            tabControl.TabPages.Remove(tabWelcome);
            this.Text = CaptionText();

            // delegate for PackageOpen init
            Del_Open = new DelegatePackageOpen(this.PackageOpen);

            tabControl.Visible = false;
            panelWelcome.Visible = !tabControl.Visible;
            regLoaded = false;
            dirty = dirtyIcon = false;
            virtPackage = new VirtPackage();
            mru = new MRU("Software\\Cameyo\\Packager\\MRU");

            fsEditor = new FileSystemEditor(virtPackage, fsFolderTree, fsFilesList,
                fsFolderInfoFullName, fsFolderInfoIsolationCombo, fsAddBtn, fsRemoveBtn, fsAddEmptyDirBtn, fsSaveFileAsBtn, fsAddDirBtn);
            regEditor = new RegistryEditor(virtPackage, new RegistryEditor.DelegateRequireElevation(RequireElevation),
                regFolderTree, regFilesList, regFolderInfoFullName, regFolderInfoIsolationCombo, regRemoveBtn, regEditBtn);

            regFilesList.DoubleClickActivation = true;
            Editors = new Control[] { tbFile, tbValue, tbType, tbSize };

            EnableDisablePackageControls(false);       // No package opened yet; disable Save menu etc
            if (packageExeFile != "" && !packageExeFile.Equals("/OPEN", StringComparison.InvariantCultureIgnoreCase))
            {
                if (PackageOpen(packageExeFile) && notifyPackageBuilt)
                {
                    PackageBuiltNotify packageBuiltNotify = new PackageBuiltNotify();
                    String friendlyPath = packageExeFile;
                    int pos = friendlyPath.ToUpper().IndexOf("\\DOCUMENTS\\");
                    if (pos == -1) pos = friendlyPath.ToUpper().IndexOf("\\MY DOCUMENTS\\");
                    if (pos != -1) friendlyPath = friendlyPath.Substring(pos + 1);

                    System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
                    packageBuiltNotify.Do(PackageEditor.Messages.Messages.packageBuiltOk, packageExeFile, friendlyPath, "PackageBuiltNotify");
                }
            }

            #if DropBox
            if (!System.IO.File.Exists(Application.StartupPath + "\\AppLimit.CloudComputing.oAuth.dll")
                || !System.IO.File.Exists(Application.StartupPath + "\\AppLimit.CloudComputing.SharpBox.dll")
                || !System.IO.File.Exists(Application.StartupPath + "\\Newtonsoft.Json.Net20.dll"))
            {
                dropboxLabel.Hide();
                dropboxButton.Hide();
                resetCredLink.Hide();
                MessageBox.Show("This version is compiled with DropBox funtionality, but one or more of the dlls needed are missing:\nAppLimit.CloudComputing.oAuth.dll\nAppLimit.CloudComputing.SharpBox.dll\nNewtonsoft.Json.Net20.dll\n\nThe button will be hidden", "Missing DLL", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            #else
            dropboxLabel.Hide();
            dropboxButton.Hide();
            //resetCredLink.Hide();
            #endif
            // Display logo
            /*string branding = "";
            try { Environment.GetEnvironmentVariable("CAMEYO_RO_PROPERTY_BRANDING"); } catch { }
            propertyDisplayLogo.Visible = !string.IsNullOrEmpty(branding);   // Freeware Cameyo does not have this feature*/

            // Culture
            langToolStripMenuItem.DropDownItems.Clear();
            ToolStripMenuItem item;
            foreach (Cameyo.OpenSrc.Common.LangItem lang in Cameyo.OpenSrc.Common.LangItem.SupportedLangs())
            {
                item = new ToolStripMenuItem(lang.DisplayName) { Tag = lang.Culture };
                item.Click += langMenuItem_Click;
                langToolStripMenuItem.DropDownItems.Add(item);
            }
            CurLanguageMenuItem().Checked = true;
        }
Пример #3
0
        private void OnEditClick(object sender, EventArgs e)
        {
            // Valid registry?
            if (workKey == null)
            {
                MessageBox.Show("No registry in this package");
                return;
            }

                // Require elevation
            if (!requireElevation())
                return;

            // Notification window
            PackageBuiltNotify packageBuiltNotify = new PackageBuiltNotify();
            String friendlyKeyName = System.IO.Path.GetFileName(System.IO.Path.GetDirectoryName(workKey.Name));
            packageBuiltNotify.Do("Registry editor will now open. Please edit entries under the key '" +
                friendlyKeyName + "'. Once you close the registry editor, your changes will be applied.",
                "", "", "RegeditExplain");

            // Set LastKey to the work key
            RegistryKey regKey;
            try
            {
                regKey = Registry.CurrentUser.CreateSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Regedit");
                regKey.SetValue("LastKey", "Computer\\" + workKey.Name);
                regKey.Close();
            }
            catch
            {
                return;
            }

            // Run RegEdit
            System.Diagnostics.ProcessStartInfo procStartInfo =
                new System.Diagnostics.ProcessStartInfo("Regedit.exe", "-m");
            System.Diagnostics.Process proc = new System.Diagnostics.Process();
            procStartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Maximized;
            proc.StartInfo = procStartInfo;
            try
            {
                proc.Start();
                proc.WaitForExit();
                OnPackageOpenUI();
                virtPackage.SaveRegWorkKey();
                dirty = true;
            }
            catch
            {
                // Exception will occur if user refuses UAC elevation for example..
            }
        }