Пример #1
0
 /// <summary>
 /// Select item in comboBoxNetLink
 /// </summary>
 /// <param name="regExePath"></param>
 private void SetRegExe(string regExePath)
 {
     if (!string.IsNullOrWhiteSpace(regExePath) && System.IO.File.Exists(regExePath))
     {
         bool found = false;
         blockGui = true;
         foreach (var item in comboBoxNetLink.Items)
         {
             if ((item as NetItem).FullPath.ToLower() == regExePath.ToLower())
             {
                 comboBoxNetLink.SelectedItem = item;
                 comboBoxNetLink.Text         = (item as NetItem).Name;
                 found = true;
                 break;
             }
         }
         if (!found)
         {
             NetItem ni = new NetItem()
             {
                 FullPath = regExePath
             };
             comboBoxNetLink.Items.Add(ni);
             comboBoxNetLink.SelectedItem = ni;
             comboBoxNetLink.Text         = ni.FullPath;
         }
         blockGui = false;
     }
 }
Пример #2
0
        private void SetValuesToForm(bool viewLog = true)
        {
            blockGui = true;
            if (SystemUtil.InternalCheckIsWow64() && !Environment.Is64BitProcess && MessageBox.Show("With a 32bit application no registry entries can be read which refer to 64bit DLLs. Please use a 64bit version of the program." + Environment.NewLine + "Close application?", "The system is 64bit but the running application is 32bit", MessageBoxButtons.OKCancel, MessageBoxIcon.Error) == DialogResult.OK)
            {
                Application.Exit();
                this.Close();
                return;
            }



            if (viewLog)
            {
                GetInfo();
            }
            labelResult.BorderStyle = BorderStyle.None;
            labelResult.BackColor   = this.BackColor;
            labelResult.Text        = "";

            #region regasm.exe
            // This is the location of the .Net Framework Registry Key
            string framworkRegPath = @"Software\Microsoft\.NetFramework";
            // Get a non-writable key from the registry
            RegistryKey netFramework = Registry.LocalMachine.OpenSubKey(framworkRegPath, false);
            // Retrieve the install root path for the framework
            string framework = netFramework.GetValue("InstallRoot").ToString();
            if (string.IsNullOrEmpty(framework) || !System.IO.Directory.Exists(framework))
            {
                framework = Environment.GetEnvironmentVariable("SystemRoot") + "\\Microsoft.NET\\";
                if (string.IsNullOrEmpty(framework) || !System.IO.Directory.Exists(framework))
                {
                    MessageBox.Show("Can`t find regasm.exe?", "EXIT", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Application.Exit();
                    return;
                }
            }
            if (!framework.EndsWith("\\"))
            {
                framework += "\\";
            }
            if (framework.ToLower().EndsWith("framework\\"))
            {
                framework = framework.Replace("Framework\\", "");
            }
            if (framework.ToLower().EndsWith("framework64\\"))
            {
                framework = framework.Replace("Framework64\\", "");
            }

            #region fill combo box regasm.exe
            comboBoxNetLink.Items.Clear();
            comboBoxNetLink.Text = string.Empty;
            if (viewLog)
            {
                Logger.Instance.AdddLog(LogType.Info, "Search in: " + framework + " for regasm.exe!", this);
            }
            string[] files = Directory.GetFiles(framework, "regasm.exe", SearchOption.AllDirectories);
            if (viewLog)
            {
                Logger.Instance.AdddLog(LogType.Info, "Found " + files.Length.ToString() + " regasm.exe files.", this);
            }

            if (files != null && files.Length > 0)
            {
                var xfiles = files.GroupBy(x => x).Select(y => y.First()).ToList();
                foreach (string item in xfiles)
                {
                    NetItem y = new NetItem()
                    {
                        FullPath = item
                    };

                    comboBoxNetLink.Items.Add(y);

                    if (Environment.Is64BitProcess && item.Contains("64"))
                    {
                        comboBoxNetLink.Text = y.Name;
                    }
                    else
                    {
                        comboBoxNetLink.Text = y.Name;
                    }
                }
            }
            #endregion

            #endregion

            LoadDllFileItems();

            checkBoxInstallinGAC.Checked            = Setting.InstallInGAC;
            checkBoxRegistry.Checked                = Setting.BuildRegistryKey;
            checkBoxCodebase.Checked                = Setting.Codebase;
            textBoxOutPath.Text                     = Setting.OutputPath;
            saveInstallLogToolStripMenuItem.Checked = Setting.SaveLogging;
            textBoxPName.Text = Setting.ProjectName;

            blockGui = false;
        }