示例#1
0
        /// <summary>
        /// 移除附加的執行指令
        /// </summary>
        /// <param name="extName">指定的副檔名 EX:".mp4"</param>
        public static bool DetachMpcBeExt(string extName)
        {
            if (RegMethod.GetMpcBeExePath(extName) == "")
            {
                return(false);
            }

            if (!RegMethod.CheckAttached(extName))
            {
                return(true);
            }

            string oldValue = RegMethod.GetOldValue(extName);

            if (oldValue != "")
            {
                RegistryKey key = RegMethod.OpenShellOpenCmdKey(extName, true);
                key.SetValue("", oldValue, RegistryValueKind.String);
                key.Close();
                RegMethod.DeleteOldValue(extName);
            }
            else
            {
                return(false);
            }

            return(true);
        }
示例#2
0
        /// <summary>
        /// 附加執行到現有的MPC-BE執行指令上
        /// </summary>
        /// <param name="extName">指定的副檔名 EX:".mp4"</param>
        public static bool AttachMpcBeExt(string extName)
        {
            if (RegMethod.CheckAttached(extName))
            {
                return(false);
            }

            if (RegMethod.GetMpcBeExePath(extName) == "")
            {
                return(false);
            }

            RegMethod.CreateOldValue(extName);

            RegistryKey key = RegMethod.OpenShellOpenCmdKey(extName, true);

            if (key != null)
            {
                string oldValue     = Convert.ToString(key.GetValue(""));
                string launcherPath = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\" + AppEnum.MPC_BE_LAUNCHER_NAME;
                string newValue     = String.Format("\"{0}\" {1}", launcherPath, oldValue);
                key.SetValue("", newValue, RegistryValueKind.String);
                key.Close();
            }
            else
            {
                return(false);
            }

            return(true);
        }