Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            // Wert des Eintrags HKEY_CURRENT_USER\Software\Microsoft\Office\
            // 10.0\Word\Options\DOC-PATH lesen
            object wordDocPath = RegUtils.ReadValue(RegistryRootKeys.HKEY_CURRENT_USER,
                                                    @"Software\Microsoft\Office\10.0\Word\Options", "DOC-PATH", null);

            if (wordDocPath != null)
            {
                Console.WriteLine(wordDocPath);
            }
            else
            {
                Console.WriteLine("Eintrag nicht gefunden");
            }

            // Eintrag HKEY_CURRENT_USER\Software\Addison-Wesley\Codebook\Version so schreiben,
            // dass der Eintrag inklusive allen Schlüsseln automatisch angelegt wird,
            // falls er noch nicht existiert
            RegUtils.WriteValue(RegistryRootKeys.HKEY_CURRENT_USER,
                                @"Software\Addison-Wesley\Codebook", "Version", "1.0", true);

            // Eintrag HKEY_CURRENT_USER\Software\Addison-Wesley\Codebook\Samples schreiben
            RegUtils.WriteValue(RegistryRootKeys.HKEY_CURRENT_USER,
                                @"Software\Addison-Wesley\Codebook\Samples", "Registry",
                                "c:\\Samples\\Registry", true);

            // Schlüssel HKEY_CURRENT_USER\Software\Addison-Wesley\Codebook\Samples löschen
            RegUtils.DeleteKey(RegistryRootKeys.HKEY_CURRENT_USER,
                               @"Software\Addison-Wesley\Codebook\Samples");

            Console.WriteLine("Fertig");
            Console.ReadLine();
        }
Ejemplo n.º 2
0
        private void RenameKeys()
        {
            foreach (var registryKeyEntryViewModel in Keys)
            {
                if (registryKeyEntryViewModel.WillRename &&
                    !string.IsNullOrEmpty(registryKeyEntryViewModel.Name) &&
                    !string.IsNullOrWhiteSpace(registryKeyEntryViewModel.Name) &&
                    !string.IsNullOrEmpty(registryKeyEntryViewModel.NewName) &&
                    !string.IsNullOrWhiteSpace(registryKeyEntryViewModel.NewName))
                {
                    try
                    {
                        bool success = RegUtils.RenameSubKey(_overlayRegistryKey, registryKeyEntryViewModel.Name, registryKeyEntryViewModel.NewName);
                        if (!success)
                        {
                            MessageBox.Show(Application.Current.MainWindow, "Rename failed", App.MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Error);
                            break;
                        }
                    }
                    catch (Exception ex) when(ex is UnauthorizedAccessException || ex is SecurityException)
                    {
                        MessageBox.Show(Application.Current.MainWindow, "Unauthorised access, try running as administrator", App.MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Error);
                        break;
                    }
                    catch (IOException ex)
                    {
                        MessageBox.Show(Application.Current.MainWindow, ex.Message, App.MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
            }

            Init();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 获取已安装Python版本,存放于PyUtils类的全局静态变量PythonVersions中。
        /// </summary>
        public static void GetPyVersions()
        {
            PythonVersions.Clear();
            RegistryKey key = Registry.LocalMachine;

            if (RegUtils.IsItemExists(key, @"SOFTWARE\Python\PythonCore"))
            {
                RegistryKey pyVersionKey = key.OpenSubKey(@"SOFTWARE\Python\PythonCore");
                string[]    pyVersions   = pyVersionKey.GetSubKeyNames();
                foreach (string version in pyVersions)
                {
                    string eachPyVarsionPath = @"SOFTWARE\Python\PythonCore\" + version + @"\InstallPath";
                    if (RegUtils.IsItemExists(key, eachPyVarsionPath))
                    {
                        RegistryKey eachPyVerKey = key.OpenSubKey(eachPyVarsionPath);
                        string      pyPath       = eachPyVerKey.GetValue("").ToString();
                        pyPath = FilePathUtils.RemovePathEndBackslash(pyPath);
                        PyUtils.PythonVersions.Add(version, pyPath);
                        eachPyVerKey.Close();
                    }
                }
                pyVersionKey.Close();
            }
            // 计算冗余值列表
            pythonBinaryDuplicatePath.Clear();
            foreach (string version in PythonVersions.Keys)
            {
                pythonBinaryDuplicatePath.Add(PythonVersions[version]);
                pythonBinaryDuplicatePath.Add(PythonVersions[version] + "\\Scripts");
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 把Path变量中的C:\Windows替换为%SystemRoot%的引用形式
        /// </summary>
        /// <returns>返回已经替换成系统引用后的Path变量副本</returns>
        public static string[] ReplacePathSystemRootReference()
        {
            string systemRootValue = Environment.GetFolderPath(Environment.SpecialFolder.Windows);
            string systemRootName  = "%SystemRoot%";

            string[] pathValues = RegUtils.GetPathVariable(false);
            for (int i = 0; i < pathValues.Length; i++)
            {
                string prefix;
                // 检测路径是否是C:\Windows打头
                if (pathValues[i].Length >= systemRootValue.Length)
                {
                    prefix = pathValues[i].Substring(0, systemRootValue.Length);
                    if (prefix.Equals(systemRootValue, StringComparison.CurrentCultureIgnoreCase))
                    {
                        pathValues[i] = pathValues[i].Replace(prefix, systemRootName);
                        continue;
                    }
                }
                // 否则,规整大小写
                if (pathValues[i].Length >= systemRootName.Length)
                {
                    prefix = pathValues[i].Substring(0, systemRootName.Length);
                    if (prefix.Equals(systemRootName, StringComparison.CurrentCultureIgnoreCase) && !prefix.Equals(systemRootName))
                    {
                        pathValues[i] = pathValues[i].Replace(prefix, systemRootName);
                    }
                }
            }
            return(pathValues);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 设定Python环境变量
        /// </summary>
        /// <param name="pyPath">python所在位置</param>
        public static void SetPythonValue(string pyPath)
        {
            // 先设定PYTHON_HOME变量
            VariableUtils.RunSetx(PYHOME_NAME, pyPath, true);
            if (!RegUtils.IsValueExists(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Control\Session Manager\Environment", PYHOME_NAME))
            {
                MessageBox.Show("设定PYTHON_HOME失败!请退出程序然后右键-以管理员身份运行此程序重试!", "失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            // 再设定Path变量
            // 先执行Path去重
            List <string> pathValues = new List <string>(PathValuesUtils.RemoveDuplicateValueInPathAndFormat());

            // 去除冗余路径
            ListUtils.BatchRemoveFromList(pathValues, pythonBinaryDuplicatePath);
            // 加入到Path
            if (!ListUtils.ListContainsIgnoreCase(pathValues, PATH_ADDITION_1))
            {
                pathValues.Add(PATH_ADDITION_1);
            }
            if (!ListUtils.ListContainsIgnoreCase(pathValues, PATH_ADDITION_2))
            {
                pathValues.Add(PATH_ADDITION_2);
            }
            // 保存Path
            if (!VariableUtils.SavePath(pathValues.ToArray()))
            {
                MessageBox.Show("追加Path失败!请退出程序然后右键-以管理员身份运行此程序重试!也可能是Path变量总长度超出限制!", "失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            MessageBox.Show("设置完成!", "完成", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 把指定值加入到Path环境变量中去
        /// </summary>
        /// <param name="value">指定值(末尾如果有分号或者反斜杠会被去除)</param>
        /// <param name="append">为true时将值追加到Path变量之后,否则插入到最前</param>
        public static void AddValueToPath(string value, bool append)
        {
            // 先获取Path变量值
            List <string> originValues = new List <string>(RegUtils.GetPathVariable(false));

            // 处理传入值
            value = FilePathUtils.RemovePathEndBackslash(value.Replace("/", "\\"));
            // 检查重复
            if (ListUtils.ListContainsIgnoreCase(originValues, value))
            {
                MessageBox.Show("该路径已经存在于Path变量中!无需再次添加!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            // 开始加入
            if (append)
            {
                originValues.Add(value);
            }
            else
            {
                originValues.Insert(0, value);
            }
            // 保存Path变量值
            if (SavePath(originValues.ToArray()))
            {
                MessageBox.Show("已成功添加路径至Path变量!若没有立即生效,请关闭现有已打开终端或者重启电脑再试!", "完成", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("添加路径到Path变量失败!请关闭该程序然后右键-以管理员身份运行该程序再试!", "失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 7
0
 /// <summary>
 /// 返回格式化后的Path变量的副本(将斜杠换成反斜杠并去掉末尾的反斜杠)
 /// </summary>
 /// <param name="expand">是否展开其中的变量引用</param>
 /// <returns>格式化后的Path变量列表</returns>
 public static string[] GetFormatedPathValues(bool expand)
 {
     string[] pathValues = RegUtils.GetPathVariable(expand);
     for (int i = 0; i < pathValues.Length; i++)
     {
         pathValues[i] = FilePathUtils.RemovePathEndBackslash(pathValues[i].Replace("/", "\\"));
     }
     return(pathValues);
 }
Ejemplo n.º 8
0
        /// <summary>
        /// 把一个数组保存为环境变量Path的值
        /// </summary>
        /// <param name="pathValues">给定数组</param>
        /// <returns>是否保存成功</returns>
        public static bool SavePath(string[] pathValues)
        {
            string saveTotalValue = string.Join(";", pathValues) + ";";

            RunSetx("Path", saveTotalValue, true);
            if (saveTotalValue.Equals(string.Join(";", RegUtils.GetPathVariable(false)) + ";"))
            {
                return(true);
            }
            return(false);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 设定JDK环境变量
        /// </summary>
        /// <param name="javaPath">jdk所在的路径</param>
        /// <param name="isJDK9AndAbove">是否是jdk9及其以上版本的jdk</param>
        public static void SetJDKValue(string javaPath, bool isJDK9AndAbove)
        {
            RegistryKey key   = Registry.LocalMachine;
            RegistryKey EVKey = key.OpenSubKey(@"SYSTEM\CurrentControlSet\Control\Session Manager\Environment", true);

            // 先设定JAVA_HOME变量
            VariableUtils.RunSetx("JAVA_HOME", javaPath, true);
            if (!RegUtils.IsValueExists(key, @"SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "JAVA_HOME"))
            {
                MessageBox.Show("设定JAVA_HOME失败!请退出程序然后右键-以管理员身份运行此程序重试!", "失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            // 再设定classpath变量
            if (isJDK9AndAbove)
            {
                if (RegUtils.IsValueExists(key, @"SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "classpath"))
                {
                    EVKey.DeleteValue("classpath");
                }
            }
            else
            {
                if (!RegUtils.IsValueExists(key, @"SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "classpath") || !EVKey.GetValue("classpath").Equals(CLASSPATH_VALUE))
                {
                    VariableUtils.RunSetx("classpath", CLASSPATH_VALUE, true);
                }
            }
            EVKey.Close();
            key.Close();
            if (!isJDK9AndAbove && !RegUtils.IsValueExists(key, @"SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "classpath"))
            {
                MessageBox.Show("设定classpath失败!请退出程序然后右键-以管理员身份运行此程序重试!", "失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            // 最后设定Path变量
            // 执行Path去重
            List <string> pathValues = new List <string>(PathValuesUtils.RemoveDuplicateValueInPathAndFormat());

            // 去除冗余的Java bin路径
            ListUtils.BatchRemoveFromList(pathValues, javaBinaryDuplicatePath);
            // 添加到Path
            if (!ListUtils.ListContainsIgnoreCase(pathValues, ADD_PATH_VALUE))
            {
                pathValues.Add(ADD_PATH_VALUE);
            }
            // 保存Path
            if (!VariableUtils.SavePath(pathValues.ToArray()))
            {
                MessageBox.Show("追加Path值失败!请退出程序然后右键-以管理员身份运行此程序重试!也可能是Path变量总长度超出限制!", "失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            MessageBox.Show("设置完成!", "完成", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Ejemplo n.º 10
0
 /// <summary>
 /// 管理Path窗口初始化
 /// </summary>
 private void ManagePathForm_Load(object sender, EventArgs e)
 {
     string[] pathValues = RegUtils.GetPathVariable(false);
     foreach (string value in pathValues)
     {
         pathContentValue.Items.Add(value);
     }
     buttonToolTip.SetToolTip(up, "上移选定元素");
     buttonToolTip.SetToolTip(down, "下移选定元素");
     buttonToolTip.SetToolTip(remove, "移除选定元素");
     buttonToolTip.SetToolTip(add, "在选定元素之后插入路径,若未选择元素则在尾部插入");
     buttonToolTip.SetToolTip(edit, "编辑所选元素,也可以双击相应的元素进行编辑");
 }
Ejemplo n.º 11
0
        public virtual string GetInstallLocationFromProductCode(string productCode, out string productName)
        {
            string issProdKey = RegUtils.REG_KEY32 + productCode + "_is1";
            var    key        = RegUtils.OpenKey(issProdKey);

            if (null == key)
            {
                issProdKey = RegUtils.REG_KEY64 + productCode;
                key        = RegUtils.OpenKey(issProdKey);
            }
            productName = RegUtils.GetDisplayName(key);
            return(RegUtils.GetInstallLocation(key));
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 检测已安装Adopt OpenJDK版本,信息储存至JDKUtils类的全局静态变量JDKVersions中。
        /// </summary>
        private static void getAdpotJDKVersion()
        {
            RegistryKey key = Registry.LocalMachine;

            // 检测Hotspot VM JDK
            if (RegUtils.IsItemExists(key, @"SOFTWARE\Temurin\JDK"))
            {
                RegistryKey jdkVersionKey    = key.OpenSubKey(@"SOFTWARE\Temurin\JDK");
                string[]    adoptJDKVersions = jdkVersionKey.GetSubKeyNames();
                foreach (string adoptJDKVersion in adoptJDKVersions)
                {
                    RegistryKey infoKey = jdkVersionKey.OpenSubKey(adoptJDKVersion + @"\hotspot\MSI");
                    string      path    = infoKey.GetValue("Path").ToString();
                    path = FilePathUtils.RemovePathEndBackslash(path);
                    JDKVersions.Add(adoptJDKVersion + " - Adopt Hotspot OpenJDK", path);
                    infoKey.Close();
                }
                jdkVersionKey.Close();
            }
            if (RegUtils.IsItemExists(key, @"SOFTWARE\Eclipse Foundation\JDK"))
            {
                RegistryKey jdkVersionKey    = key.OpenSubKey(@"SOFTWARE\Eclipse Foundation\JDK");
                string[]    adoptJDKVersions = jdkVersionKey.GetSubKeyNames();
                foreach (string adoptJDKVersion in adoptJDKVersions)
                {
                    RegistryKey infoKey = jdkVersionKey.OpenSubKey(adoptJDKVersion + @"\hotspot\MSI");
                    string      path    = infoKey.GetValue("Path").ToString();
                    path = FilePathUtils.RemovePathEndBackslash(path);
                    JDKVersions.Add(adoptJDKVersion + " - Adopt Hotspot OpenJDK", path);
                    infoKey.Close();
                }
                jdkVersionKey.Close();
            }
            // 检测OpenJ9 VM JDK
            if (RegUtils.IsItemExists(key, @"SOFTWARE\Semeru\JDK"))
            {
                RegistryKey jdkVersionKey    = key.OpenSubKey(@"SOFTWARE\Semeru\JDK");
                string[]    adoptJDKVersions = jdkVersionKey.GetSubKeyNames();
                foreach (string adoptJDKVersion in adoptJDKVersions)
                {
                    RegistryKey infoKey = jdkVersionKey.OpenSubKey(adoptJDKVersion + @"\openj9\MSI");
                    string      path    = infoKey.GetValue("Path").ToString();
                    path = FilePathUtils.RemovePathEndBackslash(path);
                    JDKVersions.Add(adoptJDKVersion + " - Adopt OpenJ9 OpenJDK", path);
                    infoKey.Close();
                }
                jdkVersionKey.Close();
            }
            key.Close();
        }
Ejemplo n.º 13
0
    /// <summary>
    /// Retrieves data about multiple verbs (executable commands) from the registry.
    /// </summary>
    /// <param name="typeKey">The registry key containing information about the file type / protocol the verbs belong to.</param>
    /// <param name="commandMapper">Provides best-match command-line to <see cref="Command"/> mapping.</param>
    /// <returns>A list of detected <see cref="Verb"/>.</returns>
    private static IEnumerable <Verb> GetVerbs(RegistryKey typeKey, CommandMapper commandMapper)
    {
        #region Sanity checks
        if (typeKey == null)
        {
            throw new ArgumentNullException(nameof(typeKey));
        }
        if (commandMapper == null)
        {
            throw new ArgumentNullException(nameof(commandMapper));
        }
        #endregion

        return(RegUtils.GetSubKeyNames(typeKey, "shell").Select(verbName => GetVerb(typeKey, commandMapper, verbName)).WhereNotNull());
    }
Ejemplo n.º 14
0
        /// <summary>
        /// 检测已安装Azul Zulu OpenJDK版本,信息储存至JDKUtils类的全局静态变量JDKVersions中。
        /// </summary>
        private static void getAzulZuluJDKVersion()
        {
            RegistryKey key = Registry.LocalMachine;

            if (RegUtils.IsItemExists(key, @"SOFTWARE\Azul Systems\Zulu"))
            {
                RegistryKey jdkVersionKey   = key.OpenSubKey(@"SOFTWARE\Azul Systems\Zulu");
                string[]    zuluJDKVersions = jdkVersionKey.GetSubKeyNames();
                foreach (string zuluJDKVersion in zuluJDKVersions)
                {
                    RegistryKey infoKey = jdkVersionKey.OpenSubKey(zuluJDKVersion);
                    string      path    = infoKey.GetValue("InstallationPath").ToString();
                    path = FilePathUtils.RemovePathEndBackslash(path);
                    JDKVersions.Add(zuluJDKVersion + " - Azul Zulu OpenJDK", path);
                    infoKey.Close();
                }
                jdkVersionKey.Close();
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// 检测已安装Microsoft JDK版本,信息储存至JDKUtils类的全局静态变量JDKVersions中。
        /// </summary>
        private static void getMicrosoftJDKVersion()
        {
            RegistryKey key = Registry.LocalMachine;

            if (RegUtils.IsItemExists(key, @"SOFTWARE\Microsoft\JDK"))
            {
                RegistryKey msJDKVersionKey = key.OpenSubKey(@"SOFTWARE\Microsoft\JDK");
                string[]    msJDKVersions   = msJDKVersionKey.GetSubKeyNames();
                foreach (string msJDKVersion in msJDKVersions)
                {
                    RegistryKey jdkInfoKey = msJDKVersionKey.OpenSubKey(msJDKVersion + @"\hotspot\MSI");
                    string      path       = jdkInfoKey.GetValue("Path").ToString();
                    path = FilePathUtils.RemovePathEndBackslash(path);
                    JDKVersions.Add(msJDKVersion + " - Microsoft Build OpenJDK", path);
                    jdkInfoKey.Close();
                }
                msJDKVersionKey.Close();
            }
            key.Close();
        }
Ejemplo n.º 16
0
        /// <summary>
        /// 从Path环境变量中移除不存在的路径
        /// </summary>
        /// <returns>返回移除了不存在的路径后的Path变量</returns>
        public static string[] RemoveNotExistPathInPathValues()
        {
            List <string> result = new List <string>(RegUtils.GetPathVariable(false));
            Dictionary <string, string> variables = GetVariablesInPath();
            string eachPath;

            for (int i = 0; i < result.Count; i++)
            {
                // 如果这个值中包含%,说明是变量引用形式,获取其实际值
                if (result[i].Contains("%"))
                {
                    // 变量列表中不存在该值,说明这个值是不存在的路径
                    eachPath = FilePathUtils.RemovePathEndBackslash(result[i].Replace("/", "\\"));
                    if (!variables.ContainsKey(eachPath))
                    {
                        result.RemoveAt(i);
                        i--;
                        continue;
                    }
                    eachPath = FilePathUtils.RemovePathEndBackslash(variables[eachPath].Replace("/", "\\"));
                    // 否则,进一步检测其对应路径是否存在
                    if (!Directory.Exists(eachPath) && !File.Exists(eachPath))
                    {
                        result.RemoveAt(i);
                        i--;
                    }
                }
                else
                {
                    // 否则就是普通路径,检测是否存在即可
                    eachPath = FilePathUtils.RemovePathEndBackslash(result[i].Replace("/", "\\"));
                    if (!Directory.Exists(eachPath) && !File.Exists(eachPath))
                    {
                        result.RemoveAt(i);
                        i--;
                    }
                }
            }
            return(result.ToArray());
        }
Ejemplo n.º 17
0
        /// <summary>
        /// 发送短信
        /// </summary>
        /// <param name="phone"></param>
        /// <returns></returns>
        protected Result <String> SendValidMessage(String phone)
        {
            Result <String> result = Result <String> .CreateInstance(ResultCode.Fail);

            //电话是否正确
            if (!RegUtils.ValidPhoneNumber(phone))
            {
                result.message = "请输入正确的手机号";
                return(result);
            }
            //手机号是否已经被医生注册
            if (UserService.IsPhoneExist(phone))
            {
                result.message = "该手机号已经被注册";
                return(result);
            }
            //短信是否在1分钟内已经发送过了。
            if (smsValidService.IsSended(SmsValidType.DoctorRegisteValid, phone))
            {
                result.message = "请在1分钟之后再请求短信发送";
                return(result);
            }

            //发送短信验证
            String validCode = random.Next(1000, 9999).ToString();

            if (!SmsUtils.SendValidCode(phone, validCode))
            {
                result.message = "服务器连接错误:短信发送失败";
                return(result);
            }
            if (!smsValidService.SendSmsValid(GetSmsValidType(), phone, validCode))
            {
                result.message = "服务器错误:获取短信验证失败";
                return(result);
            }
            result.SetSuccess();
            result.message = validCode;
            return(result);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// 检测已安装Oracle JDK版本,信息储存至JDKUtils类的全局静态变量JDKVersions中。
        /// </summary>
        private static void getOracleJDKVersion()
        {
            RegistryKey key = Registry.LocalMachine;

            //检测jdk8及其以下版本
            if (RegUtils.IsItemExists(key, @"SOFTWARE\JavaSoft\Java Development Kit"))
            {
                RegistryKey jdkOldVersionsKey = key.OpenSubKey(@"SOFTWARE\JavaSoft\Java Development Kit");
                string[]    jdkOldVersions    = jdkOldVersionsKey.GetSubKeyNames();
                foreach (string version in jdkOldVersions)
                {
                    if (Array.IndexOf(NOT_ADD_VERSION_VALUE, version) == -1)
                    {
                        RegistryKey jdkVersionKey = key.OpenSubKey(@"SOFTWARE\JavaSoft\Java Development Kit\" + version);
                        string      path          = jdkVersionKey.GetValue("JavaHome").ToString();
                        path = FilePathUtils.RemovePathEndBackslash(path);
                        JDKVersions.Add(version + " - Oracle JDK", path);
                        jdkVersionKey.Close();
                    }
                }
                jdkOldVersionsKey.Close();
            }
            //检测jdk9及其以上版本
            if (RegUtils.IsItemExists(key, @"SOFTWARE\JavaSoft\JDK"))
            {
                RegistryKey jdkNewVersionsKey = key.OpenSubKey(@"SOFTWARE\JavaSoft\JDK");
                string[]    jdkNewVersions    = jdkNewVersionsKey.GetSubKeyNames();
                foreach (string version in jdkNewVersions)
                {
                    RegistryKey jdkVersionKey = key.OpenSubKey(@"SOFTWARE\JavaSoft\JDK\" + version);
                    string      path          = jdkVersionKey.GetValue("JavaHome").ToString();
                    path = FilePathUtils.RemovePathEndBackslash(path);
                    JDKVersions.Add(version + " - Oracle JDK", path);
                    jdkVersionKey.Close();
                }
                jdkNewVersionsKey.Close();
            }
        }
Ejemplo n.º 19
0
        public void SaveFirstLogin()
        {
            if (ctx.viewer.IsLogin)
            {
                echoError("对不起,您已经登录");
                return;
            }

            Object connectType = ctx.web.SessionGet("__connectType");

            if (connectType == null)
            {
                echoError("无效的 connect type");
                return;
            }

            AuthConnect connect = AuthConnectFactory.GetConnect(connectType.ToString());

            if (connect == null)
            {
                echoError("此连接类型不存在:" + connectType);
                return;
            }

            AccessToken accessToken = getAccessToken();

            OAuthUserProfile userProfile = connect.GetUserProfile(accessToken);

            if (userProfile == null)
            {
                echoError("无法获取正常 user profile");
                return;
            }

            accessToken.Name = userProfile.Name;

            // 注册用户
            User user = new User();

            user.Name = ctx.Post("userName");
            user.Url  = ctx.Post("userUrl");

            Result result = userService.RegisterNoPwd(user);

            if (result.HasErrors)
            {
                echoError(result);
                return;
            }

            result = AvatarUploader.SaveRemote(userProfile.PicUrlBig, user.Id);
            if (result.IsValid)
            {
                user.Pic = result.Info.ToString();
                user.update();
            }
            else
            {
                echoError(result);
                return;
            }

            // 是否开启空间
            RegUtils.CheckUserSpace(user, ctx);

            // 绑定用户
            Result saveResult = connectService.Create(user, connect.GetType().FullName, accessToken);

            if (saveResult.IsValid)
            {
                UserConnect userConnect = saveResult.Info as UserConnect;
                loginService.Login(user, userConnect.Id, LoginTime.OneWeek, ctx.Ip, ctx);   // 登录
                echoRedirect("登录成功", "/");
            }
            else
            {
                echoError(saveResult);
            }
        }
Ejemplo n.º 20
0
        private void ok_Click(object sender, EventArgs e)
        {
            uninstalling.Visible = true;
            ok.Enabled           = false;
            cancel.Enabled       = false;
            Configure cfg = JsonConvert.DeserializeObject <Configure>(File.ReadAllText(WORK_PLACE + "\\cfg.ezcfg"));

            if (!cfg.RunBeforeUnSetup.Equals(""))
            {
                state.Text = "执行卸载前命令...";
                Application.DoEvents();
                Environment.CurrentDirectory = appPath;
                string totalCommand = cfg.RunBeforeUnSetup;
                if (totalCommand.Contains(" "))
                {
                    string command = totalCommand.Substring(0, totalCommand.IndexOf(" "));
                    string args    = totalCommand.Substring(totalCommand.IndexOf(" ") + 1);
                    TerminalUtils.RunCommand(command, args);
                }
                else
                {
                    Process.Start(totalCommand);
                }
            }
            if (cfg.GenerateShortcut)
            {
                state.Text = "移除快捷方式...";
                Application.DoEvents();
                try
                {
                    if (Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.CommonPrograms) + "\\" + cfg.Title))
                    {
                        Directory.Delete(Environment.GetFolderPath(Environment.SpecialFolder.CommonPrograms) + "\\" + cfg.Title, true);
                    }
                    if (File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "\\" + cfg.Title + ".lnk"))
                    {
                        File.Delete(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "\\" + cfg.Title + ".lnk");
                    }
                }
                catch
                {
                    //none
                }
            }
            if (cfg.AddBootOption)
            {
                state.Text = "移除开机启动项...";
                Application.DoEvents();
                RegUtils.OperateBootOption(cfg.Title, "", false);
            }
            state.Text = "移除程序信息注册表...";
            Application.DoEvents();
            RegUtils.OperateAppUninstallItem(new AppUninstallInfo(cfg.Title, ""), false);
            state.Text = "移除文件...";
            Application.DoEvents();
            string[] dirList  = Directory.GetDirectories(appPath);
            string[] fileList = Directory.GetFiles(appPath);
            foreach (string dir in dirList)
            {
                try
                {
                    Directory.Delete(dir, true);
                }
                catch
                {
                    //none
                }
            }
            foreach (string file in fileList)
            {
                if (!file.Equals(selfPath))
                {
                    try
                    {
                        File.Delete(file);
                    }
                    catch
                    {
                        //none
                    }
                }
            }
            File.WriteAllText(WORK_PLACE + "\\delete.vbs", "wscript.sleep 1000*1\r\nset f=createobject(\"Scripting.FileSystemObject\")\r\nf.DeleteFolder(\"" + appPath + "\"),true\r\nf.DeleteFolder(\"" + WORK_PLACE + "\"),true\r\ncall MsgBox(\"卸载成功!\", 64, \"完成\")", Encoding.GetEncoding("gbk"));
            Process.Start(WORK_PLACE + "\\delete.vbs");
            Application.Exit();
        }
Ejemplo n.º 21
0
        /// <summary>
        /// 安装时执行
        /// </summary>
        public static void DoInstall()
        {
            //开始执行安装
            if (!Directory.Exists(ConfigUtils.GlobalConfigure.InstallPath))
            {
                Directory.CreateDirectory(ConfigUtils.GlobalConfigure.InstallPath);
            }
            TerminalResult result = new TerminalResult();

            TerminalUtils.RunCommandAsynchronously("7z", "x " + TextUtils.SurroundByDoubleQuotes(ConfigUtils.WORK_PLACE + "\\data.7z") + " -o" + TextUtils.SurroundByDoubleQuotes(ConfigUtils.GlobalConfigure.InstallPath), result);
            //安装完成,写入相应注册表和创建快捷方式
            if (ConfigUtils.GlobalConfigure.GenerateShortcut)
            {
                foreach (string sitem in ConfigUtils.GlobalConfigure.ShortcutList)
                {
                    string[] shortInfo       = sitem.Split('|');               //分割后得到分别是原文件名、快捷方式名和运行参数(可能没有参数)
                    string   originFilePath  = ConfigUtils.GlobalConfigure.InstallPath + "\\" + shortInfo[0];
                    string   destDesktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "\\" + shortInfo[1];
                    if (shortInfo.Length == 2)
                    {
                        IOUtils.CreateShortcut(originFilePath, destDesktopPath);
                    }
                    else
                    {
                        IOUtils.CreateShortcut(originFilePath, destDesktopPath, shortInfo[2]);
                    }
                    if (!Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.CommonPrograms) + "\\" + ConfigUtils.GlobalConfigure.Title))
                    {
                        Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.CommonPrograms) + "\\" + ConfigUtils.GlobalConfigure.Title);
                    }
                    string destMenuPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonPrograms) + "\\" + ConfigUtils.GlobalConfigure.Title + "\\" + shortInfo[1];
                    if (shortInfo.Length == 2)
                    {
                        IOUtils.CreateShortcut(originFilePath, destMenuPath);
                    }
                    else
                    {
                        IOUtils.CreateShortcut(originFilePath, destMenuPath, shortInfo[2]);
                    }
                }
            }
            if (ConfigUtils.GlobalConfigure.AddBootOption)
            {
                RegUtils.OperateBootOption(ConfigUtils.GlobalConfigure.Title, ConfigUtils.GlobalConfigure.InstallPath + "\\" + ConfigUtils.GlobalConfigure.MainEXE, true);
            }
            //如果生成卸载程序,则加入注册表程序信息
            if (ConfigUtils.GlobalConfigure.GenerateUninstall)
            {
                AppUninstallInfo info = new AppUninstallInfo();
                info.DisplayName     = ConfigUtils.GlobalConfigure.Title;
                info.InstallPath     = ConfigUtils.GlobalConfigure.InstallPath;
                info.UninstallString = ConfigUtils.GlobalConfigure.InstallPath + "\\uninstall.exe";
                string iconPath = ConfigUtils.GlobalConfigure.MainEXE;
                if (iconPath.Equals(""))
                {
                    iconPath = "uninstall.exe";
                }
                info.DisplayIcon    = ConfigUtils.GlobalConfigure.InstallPath + "\\" + iconPath;
                info.EstimatedSize  = IOUtils.Get7zOriginSize(ConfigUtils.WORK_PLACE + "\\data.7z") / 1024;
                info.DisplayVersion = ConfigUtils.GlobalConfigure.Version;
                info.Publisher      = ConfigUtils.GlobalConfigure.Publisher;
                RegUtils.OperateAppUninstallItem(info, true);
                if (!Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.CommonPrograms) + "\\" + ConfigUtils.GlobalConfigure.Title))
                {
                    Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.CommonPrograms) + "\\" + ConfigUtils.GlobalConfigure.Title);
                }
                IOUtils.CreateShortcut(ConfigUtils.GlobalConfigure.InstallPath + "\\uninstall.exe", Environment.GetFolderPath(Environment.SpecialFolder.CommonPrograms) + "\\" + ConfigUtils.GlobalConfigure.Title + "\\卸载程序");
            }
        }
Ejemplo n.º 22
0
        private void button2_Click(object sender, EventArgs e)
        {
            RegUtils.Test();
            string input = @"E:\useful\Thkj-Resource\origin\Fussion\src\Application\Fusion.Context.BasicInfo.Application\Services\Product\Brand1Service.cs;";
            string ret   = (new RegUtils()).replaceAllBeforeFirststring(input, @"\Fussion", AppDomain.CurrentDomain.BaseDirectory);

            //先这里构建原始数据,后期再动态
            string cN = txtClassName.Text;
            List <MemberFromInfo> listMember = new List <MemberFromInfo>();

            listMember.Add(new MemberFromInfo("TBUper", cN));
            listMember.Add(new MemberFromInfo("Id", "Guid"));
            listMember.Add(new MemberFromInfo(cN + "Code", "string"));
            listMember.Add(new MemberFromInfo(cN + "Name", "string"));
            listMember.Add(new MemberFromInfo("Active", "bool"));
            listMember.Add(new MemberFromInfo("Remark", "string"));
            listMember.Add(new MemberFromInfo("CreateTime", "DateTime"));
            listMember.Add(new MemberFromInfo("UpdateTime", "DateTime"));
            listMember.Add(new MemberFromInfo("RowVersion", "byte[]"));
            string content;

            #region
            string file = AppDomain.CurrentDomain.BaseDirectory + string.Format(@"Fussion\src\Application\Fusion.Context.BasicInfo.Application\Models\Product\" + "{0}s\\{0}Model.cs"
                                                                                , cN);
            content = (new ClassApplication()).GetApplicationModel(listMember).Replace("_左括号_", "{").Replace("_右括号_", "}");
            FileUtils.WriteToFile(file, content);
            System.Diagnostics.Process.Start(file);
            #endregion
            string fileAppStore = AppDomain.CurrentDomain.BaseDirectory
                                  + string.Format(@"E:\useful\Thkj-Resource\origin\Fussion\src\Application\Fusion.Context.BasicInfo.Application\Services\Interfaces\Product\"
                                                  + "I{0}Service.cs", cN);

            #region
            file = AppDomain.CurrentDomain.BaseDirectory + string.Format(
                @"	Fussion\src\Application\Fusion.Context.BasicInfo.Application\Models\Product\_左括号_0_右括号_s\_左括号_0_右括号_Model.cs	", cN);
            content = (new ClassApplication()).GetApplicationModel(listMember).Replace("_左括号_", "{").Replace("_右括号_", "}");
            FileUtils.WriteToFile(file, content);
            System.Diagnostics.Process.Start(file);
            #endregion
            #region
            file = AppDomain.CurrentDomain.BaseDirectory + string.Format(
                @"	Fussion\src\Application\Fusion.Context.BasicInfo.Application\Services\Interfaces\Product\I_左括号_0_右括号_Service.cs	", cN);
            content = (new ClassApplication()).GetApplicationModel(listMember).Replace("_左括号_", "{").Replace("_右括号_", "}");
            FileUtils.WriteToFile(file, content);
            System.Diagnostics.Process.Start(file);
            #endregion
            #region
            file = AppDomain.CurrentDomain.BaseDirectory + string.Format(
                @"	Fussion\src\Application\Fusion.Context.BasicInfo.Application\Services\Product\_左括号_0_右括号_Service.cs	", cN);
            content = (new ClassApplication()).GetApplicationModel(listMember).Replace("_左括号_", "{").Replace("_右括号_", "}");
            FileUtils.WriteToFile(file, content);
            System.Diagnostics.Process.Start(file);
            #region
            #endregion
            file = AppDomain.CurrentDomain.BaseDirectory + string.Format(
                @"	Fussion\src\Domain\Fusion.Context.BasicInfo.Domain\Models\Product\_左括号_0_右括号_s\_左括号_0_右括号_.cs	", cN);
            content = (new ClassApplication()).GetApplicationModel(listMember).Replace("_左括号_", "{").Replace("_右括号_", "}");
            FileUtils.WriteToFile(file, content);
            System.Diagnostics.Process.Start(file);
            #region
            #endregion
            file = AppDomain.CurrentDomain.BaseDirectory + string.Format(
                @"	Fussion\src\Domain\Fusion.Context.BasicInfo.Domain\Repositories\Product\I_左括号_0_右括号_Repository.cs	", cN);
            content = (new ClassApplication()).GetApplicationModel(listMember).Replace("_左括号_", "{").Replace("_右括号_", "}");
            FileUtils.WriteToFile(file, content);
            System.Diagnostics.Process.Start(file);
            #endregion
            #region
            file = AppDomain.CurrentDomain.BaseDirectory + string.Format(
                @"	Fussion\src\Infrastructure\Fusion.Infrastructure.Mapping.BasicInfo\Models\Product\_左括号_0_右括号_s\_左括号_0_右括号_Map.cs	", cN);
            content = (new ClassApplication()).GetApplicationModel(listMember).Replace("_左括号_", "{").Replace("_右括号_", "}");
            FileUtils.WriteToFile(file, content);
            System.Diagnostics.Process.Start(file);
            #endregion
            #region
            file = AppDomain.CurrentDomain.BaseDirectory + string.Format(
                @"	Fussion\src\Infrastructure\Fusion.Infrastructure.Repository.BasicInfo\Repositories\Product\_左括号_0_右括号_Repository.cs	", cN);
            content = (new ClassApplication()).GetApplicationModel(listMember).Replace("_左括号_", "{").Replace("_右括号_", "}");
            FileUtils.WriteToFile(file, content);
            System.Diagnostics.Process.Start(file);
            #endregion
            #region
            file = AppDomain.CurrentDomain.BaseDirectory + string.Format(
                @"	Fussion\src\User Interface\Fusion\Extjs\Fusion\classic\src\BasicInfo\model\Product\_左括号_0_右括号_s\_左括号_0_右括号_Model.js	", cN);
            content = (new ClassApplication()).GetApplicationModel(listMember).Replace("_左括号_", "{").Replace("_右括号_", "}");
            FileUtils.WriteToFile(file, content);
            System.Diagnostics.Process.Start(file);
            #endregion
            #region
            file = AppDomain.CurrentDomain.BaseDirectory + string.Format(
                @"	Fussion\src\User Interface\Fusion\Extjs\Fusion\classic\src\BasicInfo\store\Product\_左括号_0_右括号_s\_左括号_0_右括号_Store.js	", cN);
            content = (new ClassApplication()).GetApplicationModel(listMember).Replace("_左括号_", "{").Replace("_右括号_", "}");
            FileUtils.WriteToFile(file, content);
            System.Diagnostics.Process.Start(file);
            #endregion
            #region
            file = AppDomain.CurrentDomain.BaseDirectory + string.Format(
                @"	Fussion\src\User Interface\Fusion\Extjs\Fusion\classic\src\BasicInfo\view\Product\_左括号_0_右括号_s\_左括号_0_右括号_.js	", cN);
            content = (new ClassApplication()).GetApplicationModel(listMember).Replace("_左括号_", "{").Replace("_右括号_", "}");
            FileUtils.WriteToFile(file, content);
            System.Diagnostics.Process.Start(file);
            #endregion
            #region
            file = AppDomain.CurrentDomain.BaseDirectory + string.Format(
                @"	Fussion\src\User Interface\Fusion\Extjs\Fusion\classic\src\BasicInfo\view\Product\_左括号_0_右括号_s\_左括号_0_右括号_Controller.js	", cN);
            content = (new ClassApplication()).GetApplicationModel(listMember).Replace("_左括号_", "{").Replace("_右括号_", "}");
            FileUtils.WriteToFile(file, content);
            System.Diagnostics.Process.Start(file);
            #endregion
            #region
            file = AppDomain.CurrentDomain.BaseDirectory + string.Format(
                @"	Fussion\src\User Interface\Fusion\Extjs\Fusion\classic\src\BasicInfo\view\Product\_左括号_0_右括号_s\_左括号_0_右括号_Toolbar.js	", cN);
            content = (new ClassApplication()).GetApplicationModel(listMember).Replace("_左括号_", "{").Replace("_右括号_", "}");
            FileUtils.WriteToFile(file, content);
            System.Diagnostics.Process.Start(file);
            #endregion
            #region
            file = AppDomain.CurrentDomain.BaseDirectory + string.Format(
                @"	Fussion\src\User Interface\Fusion\Extjs\Fusion\classic\src\BasicInfo\view\Product\_左括号_0_右括号_s\Find_左括号_0_右括号_.js	", cN);
            content = (new ClassApplication()).GetApplicationModel(listMember).Replace("_左括号_", "{").Replace("_右括号_", "}");
            FileUtils.WriteToFile(file, content);
            System.Diagnostics.Process.Start(file);
            #endregion
            #region
            file = AppDomain.CurrentDomain.BaseDirectory + string.Format(
                @"	Fussion\src\User Interface\Fusion\Extjs\Fusion\classic\src\BasicInfo\view\Product\_左括号_0_右括号_s\Modify_左括号_0_右括号_.js	", cN);
            content = (new ClassApplication()).GetApplicationModel(listMember).Replace("_左括号_", "{").Replace("_右括号_", "}");
            FileUtils.WriteToFile(file, content);
            System.Diagnostics.Process.Start(file);
            #endregion
        }
Ejemplo n.º 23
0
 //TODO add to IProductLookUp interface in Dynamo 3.0
 //Returns product names and code tuples for products which have valid display name.
 internal virtual IEnumerable <(string DisplayName, string ProductKey)> GetProductNameAndCodeList()
 {
     return(RegUtils.GetInstalledProducts().ToList().Select(s => (s.Value.DisplayName, s.Key)).Where(s => {
         return s.DisplayName?.Contains(ProductLookUpName) ?? false;
     }));
 }
Ejemplo n.º 24
0
        private void install_Click(object sender, EventArgs e)
        {
            if (pathValue.Text.Equals(""))
            {
                MessageBox.Show("安装目录不能为空!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (!Directory.Exists(pathValue.Text.Substring(0, 3)))
            {
                MessageBox.Show("指定的安装目录所在驱动器不存在!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (Directory.Exists(pathValue.Text) && (Directory.GetFiles(pathValue.Text).Length != 0 || Directory.GetDirectories(pathValue.Text).Length != 0))
            {
                MessageBox.Show("指定的安装目录必须为空目录!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            //开始执行安装
            mainTabPanel.SelectedIndex = 3;
            if (!Directory.Exists(pathValue.Text))
            {
                Directory.CreateDirectory(pathValue.Text);
            }
            long           totalSize = IOUtils.Get7zOriginSize(ConfigUtils.WORK_PLACE + "\\data.7z");
            TerminalResult result    = new TerminalResult();

            TerminalUtils.RunCommandAsynchronously("7z", "x " + TextUtils.SurroundByDoubleQuotes(ConfigUtils.WORK_PLACE + "\\data.7z") + " -o" + TextUtils.SurroundByDoubleQuotes(pathValue.Text), result);
            int    ratio = 0;
            string curFile;

            while (!result.Finished)
            {
                try
                {
                    DirInfo info = new DirInfo();
                    BinaryUtils.GetDirectoryInfo(pathValue.Text, info);
                    ratio = (int)((float)info.Size / totalSize * 100);
                    if (ratio > 100)
                    {
                        ratio = 100;
                    }
                    List <string> fileList = info.FileList;
                    if (fileList.Count > 0)
                    {
                        curFile          = fileList[fileList.Count - 1];
                        currentFile.Text = "正在释放:" + curFile.Substring(curFile.LastIndexOf("\\") + 1);
                    }
                }
                catch
                {
                    //none
                }
                finally
                {
                    processValue.Text = ratio + "%";
                    progressBar.Value = ratio;
                    Application.DoEvents();
                }
            }
            //安装完成,写入相应注册表和创建快捷方式
            if (ConfigUtils.GlobalConfigure.GenerateShortcut && addDesktopIcon.Checked)
            {
                foreach (string sitem in ConfigUtils.GlobalConfigure.ShortcutList)
                {
                    string[] shortInfo       = sitem.Split('|');               //分割后得到分别是原文件名、快捷方式名和运行参数(可能没有参数)
                    string   originFilePath  = pathValue.Text + "\\" + shortInfo[0];
                    string   destDesktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "\\" + shortInfo[1];
                    if (shortInfo.Length == 2)
                    {
                        IOUtils.CreateShortcut(originFilePath, destDesktopPath);
                    }
                    else
                    {
                        IOUtils.CreateShortcut(originFilePath, destDesktopPath, shortInfo[2]);
                    }
                    if (!Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.CommonPrograms) + "\\" + ConfigUtils.GlobalConfigure.Title))
                    {
                        Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.CommonPrograms) + "\\" + ConfigUtils.GlobalConfigure.Title);
                    }
                    string destMenuPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonPrograms) + "\\" + ConfigUtils.GlobalConfigure.Title + "\\" + shortInfo[1];
                    if (shortInfo.Length == 2)
                    {
                        IOUtils.CreateShortcut(originFilePath, destMenuPath);
                    }
                    else
                    {
                        IOUtils.CreateShortcut(originFilePath, destMenuPath, shortInfo[2]);
                    }
                }
            }
            if (ConfigUtils.GlobalConfigure.AddBootOption && addBootOption.Checked)
            {
                RegUtils.OperateBootOption(ConfigUtils.GlobalConfigure.Title, pathValue.Text + "\\" + ConfigUtils.GlobalConfigure.MainEXE, true);
            }
            //如果生成卸载程序,则加入注册表程序信息
            if (ConfigUtils.GlobalConfigure.GenerateUninstall)
            {
                AppUninstallInfo info = new AppUninstallInfo();
                info.DisplayName     = ConfigUtils.GlobalConfigure.Title;
                info.InstallPath     = pathValue.Text;
                info.UninstallString = pathValue.Text + "\\uninstall.exe";
                string iconPath = ConfigUtils.GlobalConfigure.MainEXE;
                if (iconPath.Equals(""))
                {
                    iconPath = "uninstall.exe";
                }
                info.DisplayIcon    = pathValue.Text + "\\" + iconPath;
                info.EstimatedSize  = totalSize / 1024;
                info.DisplayVersion = ConfigUtils.GlobalConfigure.Version;
                info.Publisher      = ConfigUtils.GlobalConfigure.Publisher;
                RegUtils.OperateAppUninstallItem(info, true);
                if (!Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.CommonPrograms) + "\\" + ConfigUtils.GlobalConfigure.Title))
                {
                    Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.CommonPrograms) + "\\" + ConfigUtils.GlobalConfigure.Title);
                }
                IOUtils.CreateShortcut(pathValue.Text + "\\uninstall.exe", Environment.GetFolderPath(Environment.SpecialFolder.CommonPrograms) + "\\" + ConfigUtils.GlobalConfigure.Title + "\\卸载程序");
            }
            mainTabPanel.SelectedIndex = 4;
        }
Ejemplo n.º 25
0
        public void SaveReg()
        {
            if (ctx.viewer.IsLogin)
            {
                echo("您有帐号,并且已经登录");
                return;
            }

            if (config.Instance.Site.RegisterType == RegisterType.CloseUnlessInvite)
            {
                int    friendId   = ctx.PostInt("friendId");
                String friendCode = ctx.Post("friendCode");
                Result result     = inviteService.Validate(friendId, friendCode);
                if (result.HasErrors)
                {
                    echo(result.ErrorsHtml);
                    return;
                }
            }

            // 验证
            User user = validateUser();

            if (errors.HasErrors)
            {
                run(Register);
                return;
            }

            // 用户注册
            user = userService.Register(user, ctx);
            if ((user == null) || errors.HasErrors)
            {
                run(Register);
                return;
            }

            // 是否开启空间
            RegUtils.CheckUserSpace(user, ctx);

            // 好友处理
            RegUtils.ProcessFriend(user, ctx);

            // 是否需要审核、激活
            if (config.Instance.Site.UserNeedApprove)
            {
                user.Status = MemberStatus.Approving;
                user.update("Status");

                view("needApproveMsg");
                set("siteName", config.Instance.Site.SiteName);
            }
            else if (config.Instance.Site.EnableEmail)
            {
                if (config.Instance.Site.LoginType == LoginType.Open)
                {
                    loginService.Login(user, LoginTime.Forever, ctx.Ip, ctx);
                }

                redirectUrl(to(Done) + "?email=" + user.Email);
            }
            else
            {
                loginService.Login(user, LoginTime.Forever, ctx.Ip, ctx);
                echoRedirect(lang("registerok"), getSavedReturnUrl());
            }
        }
Ejemplo n.º 26
0
 public virtual IEnumerable <string> GetProductNameList()
 {
     return(RegUtils.GetInstalledProducts().Select(s => s.Value.DisplayName).Where(s => {
         return s?.Contains(ProductLookUpName) ?? false;
     }));
 }
Ejemplo n.º 27
0
        public virtual string GetInstallLocationFromProductName(string name)
        {
            var key = RegUtils.OpenKey(RegUtils.REG_KEY64 + name);

            return(RegUtils.GetInstallLocation(key));
        }