当前位置: 首页>>代码示例>>C#>>正文


C# RegistryKey.Close方法代码示例

本文整理汇总了C#中Microsoft.Win32.RegistryKey.Close方法的典型用法代码示例。如果您正苦于以下问题:C# RegistryKey.Close方法的具体用法?C# RegistryKey.Close怎么用?C# RegistryKey.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Win32.RegistryKey的用法示例。


在下文中一共展示了RegistryKey.Close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetRegistryStringValue

 public static string GetRegistryStringValue(RegistryKey baseKey, string strSubKey, string strValue)
 {
     object obj = null;
     string text = string.Empty;
     string result;
     try
     {
         RegistryKey registryKey = baseKey.OpenSubKey(strSubKey);
         if (registryKey == null)
         {
             result = null;
             return result;
         }
         obj = registryKey.GetValue(strValue);
         if (obj == null)
         {
             result = null;
             return result;
         }
         registryKey.Close();
         baseKey.Close();
     }
     catch (Exception ex)
     {
         text = ex.Message;
         result = null;
         return result;
     }
     result = obj.ToString();
     return result;
 }
开发者ID:Padungsak,项目名称:efinTradePlus,代码行数:31,代码来源:BusinessServiceFactory.cs

示例2: DeZip

        /// <summary>
        /// 解压缩
        /// </summary>
        /// <param name="zipname">要解压的文件名</param>
        /// <param name="zippath">要解压的文件路径</param>
        public static void DeZip(string zipname, string zippath)
        {
            try
            {
                the_Reg = Registry.ClassesRoot.OpenSubKey(@"Applications\WinRar.exe\Shell\Open\Command");
                the_Obj = the_Reg.GetValue("");
                the_rar = the_Obj.ToString();
                the_Reg.Close();
                the_rar = the_rar.Substring(1, the_rar.Length - 7);
                the_Info = " X " + zipname + " " + zippath;
                the_StartInfo = new ProcessStartInfo();
                the_StartInfo.FileName = the_rar;
                the_StartInfo.Arguments = the_Info;
                the_StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                the_Process = new Process();
                the_Process.StartInfo = the_StartInfo;
                the_Process.Start();
                the_Process.WaitForExit();

                the_Process.Close();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
开发者ID:dayuhan,项目名称:NETWORK,代码行数:31,代码来源:ZipHelper.cs

示例3: IsStartupPathUnchanged

        public bool IsStartupPathUnchanged(string appName, string pathToExe)
        {
            try
            {
                _startupKey = Registry.CurrentUser.OpenSubKey(RunKey);
                if (_startupKey == null)
                {
                    return false;
                }

                string startUpValue = _startupKey.GetValue(appName).ToString();
                if (startUpValue == pathToExe)
                {
                    return true;
                }
                return false;
            }
            catch (Exception)
            {
                return false;
            }
            finally
            {
                _startupKey.Close();
            }
        }
开发者ID:juvlarN,项目名称:vibranceGUI,代码行数:26,代码来源:RegistryController.cs

示例4: seemsForm

		public seemsForm()
        {
			InitializeComponent();

            ToolStripManager.RenderMode = ToolStripManagerRenderMode.Professional;

			this.Load += seems_Load;
			this.Resize += seems_Resize;
			this.LocationChanged += seems_LocationChanged;

			seemsRegistryKey = Registry.CurrentUser.OpenSubKey( seemsRegistryLocation );
			if( seemsRegistryKey != null )
				seemsRegistryKey.Close();

			recentFilesMenu = new MruStripMenu( recentFilesFileMenuItem, new MruStripMenu.ClickedHandler( recentFilesFileMenuItem_Click ), seemsRegistryLocation + "\\Recent File List", true );

            browseToFileDialog = new OpenDataSourceDialog();
			browseToFileDialog.InitialDirectory = "C:\\";

            DockPanelManager.RenderMode = DockPanelRenderMode.VisualStyles;

            manager = new Manager(dockPanel);

            Manager.GraphFormGotFocus += new GraphFormGotFocusHandler(Manager_GraphFormGotFocus);
            Manager.LoadDataSourceProgress += new LoadDataSourceProgressEventHandler(Manager_LoadDataSourceProgress);
		}
开发者ID:lgatto,项目名称:proteowizard,代码行数:26,代码来源:seems.cs

示例5: UtilsRegistryKey

 internal UtilsRegistryKey(UtilsRegistry root, string fullPath)
 {
     _root = root;
     _path = fullPath;
     _innerKey = _root.HiveKey.OpenSubKey(fullPath);
     _innerKey.Close();
 }
开发者ID:swatt6400,项目名称:NetOffice,代码行数:7,代码来源:UtilsRegistryKey.cs

示例6: PreferencesDialog

        /// <summary>
        /// Application preferences form
        /// </summary>
        public PreferencesDialog()
        {
            // Initialize design components
            InitializeComponent();

            // Open Windows startup registry key
            _windowsRegistryKey = Registry.CurrentUser.OpenSubKey(MainForm.REGISTRY_KEY_WINDOWS_AUTORUN, true);
            // Open application preferences registry key
            _preferencesRegistryKey = Registry.CurrentUser.OpenSubKey(MainForm.REGISTRY_KEY_PREFERENCES, true);
            // Open application server list registry key
            _serverListRegistryKey = Registry.CurrentUser.OpenSubKey(MainForm.REGISTRY_KEY_SERVER_LIST, true);

            // Get option values from registry keys
            if ((string)_preferencesRegistryKey.GetValue(MainForm.REGISTRY_VALUE_UI_UPDATE_INTERVAL) != null) numBoxFormUpdateInterval.Value = int.Parse((string)_preferencesRegistryKey.GetValue(MainForm.REGISTRY_VALUE_UI_UPDATE_INTERVAL));
            if ((string)_preferencesRegistryKey.GetValue(MainForm.REGISTRY_VALUE_UI_MINIMIZE_TO_TRAY) == "False") checkBoxMinimizeToTray.Checked = false;
            if ((string)_preferencesRegistryKey.GetValue(MainForm.REGISTRY_VALUE_UI_MINIMIZE_DISABLE_NOTIFICATIONS) == "True") checkBoxDisableTrayNotifications.Checked = true;
            if ((string)_windowsRegistryKey.GetValue(MainForm.REGISTRY_VALUE_WINDOWS_START_AT_LOGIN) == Application.ExecutablePath.ToString()) checkBoxStartAtLogin.Checked = true;
            if ((string)_preferencesRegistryKey.GetValue(MainForm.REGISTRY_VALUE_UI_MINIMIZE_AT_START) == "True") checkBoxMinimizeAtStart.Checked = true;
            if ((string)_preferencesRegistryKey.GetValue(MainForm.REGISTRY_VALUE_UI_CHECK_FOR_UPDATES_AT_START) == "False") checkBoxCheckForUpdates.Checked = false;

            // Close Windows startup registry key
            _windowsRegistryKey.Close();
            // Close application preferences registry key
            _preferencesRegistryKey.Close();
            // Close application server list registry key
            _serverListRegistryKey.Close();

            // Update server list
            UpdateServerList();
        }
开发者ID:ryonsherman,项目名称:hellanzb-remote-dotnet,代码行数:33,代码来源:PreferencesDialog.cs

示例7: registerProgram

 public bool registerProgram(string appName, string pathToExe)
 {
     try
     {
         if (!isProgramRegistered(appName))
         {
             startupKey = Registry.CurrentUser.OpenSubKey(runKey);
             if (startupKey.GetValue(appName) == null)
             {
                 startupKey.Close();
                 startupKey = Registry.CurrentUser.OpenSubKey(runKey, true);
                 startupKey.SetValue(appName, pathToExe);
             }
         }
     }
     catch (Exception)
     {
         return false;
     }
     finally
     {
         startupKey.Close();
     }
     return true;
 }
开发者ID:RisingFog,项目名称:vibranceGUI,代码行数:25,代码来源:RegistryController.cs

示例8: SetRegistryData

 public static void SetRegistryData(RegistryKey key, string path, string item, string value)
 {
     string[] keys = path.Split(new char[] {'/'},StringSplitOptions.RemoveEmptyEntries);
     try
     {
         if (keys.Count() == 0)
         {
             key.SetValue(item, value);
             key.Close();
         }
         else
         {
             string[] subKeys = key.GetSubKeyNames();
             if (subKeys.Where(s => s.ToLowerInvariant() == keys[0].ToLowerInvariant()).FirstOrDefault() != null)
             {
                 //Open subkey
                 RegistryKey sub = key.OpenSubKey(keys[0], (keys.Count() == 1));
                 if (keys.Length > 1)
                     SetRegistryData(sub, path.Substring(keys[0].Length + 1), item, value);
                 else
                     SetRegistryData(sub, string.Empty, item, value);
             }
             else
             {
                 SetRegistryData(key.CreateSubKey(keys[0]), path.Substring(keys[0].Length + 1), item, value);
             }
         }
     }
     catch { }
 }
开发者ID:Kayomani,项目名称:FAP,代码行数:30,代码来源:RegistryHelper.cs

示例9: EnZip

        /// <summary>
        /// 压缩
        /// </summary>
        /// <param name="path">要压缩文件路径</param>
        /// <param name="rarPath">要压缩的文件名</param>
        /// <param name="rarName">压缩的文件路径</param>
        public static void EnZip(string path, string rarName, string rarPath)
        {
            //   bool flag = false;
            try
            {
                the_Reg = Registry.ClassesRoot.OpenSubKey(@"Applications\WinRAR.exe\Shell\Open\Command");
                the_Obj = the_Reg.GetValue("");
                the_rar = the_Obj.ToString();
                the_Reg.Close();
                the_rar = the_rar.Substring(1, the_rar.Length - 7);
                // Directory.CreateDirectory(path);
                //
                //the_Info = " a    " + rarName + "  " + @"C:Test€70821.txt"; //文件压缩
                the_Info = " a   " + rarPath + "  " + path;
                #region 命令参数
                //// 1
                ////压缩即文件夹及其下文件
                //the_Info = " a    " + rarName + "  " + path + "  -r";
                //// 2
                ////压缩即文件夹及其下文件 设置压缩方式为 .zip
                //the_Info = " a -afzip  " + rarName + "  " + path;
                //// 3
                ////压缩文件夹及其下文件 直接设定为free.zip
                //the_Info = " a -r  " + rarName + "  " + path;
                //// 4
                ////搬迁压缩即文件夹及其下文件原文件将不存在
                //the_Info = " m  " + rarName + "  " + path;
                //// 5
                ////压缩即文件  直接设定为free.zip 只有文件 而没有文件夹
                //the_Info = " a -ep  " + rarName + "  " + path;
                //// 6
                ////加密压缩即文件夹及其下文件 密码为123456 注意参数间不要空格
                //the_Info = " a -p123456  " + rarName + "  " + path;
                #endregion

                the_StartInfo = new ProcessStartInfo();
                the_StartInfo.FileName = the_rar;
                the_StartInfo.Arguments = the_Info;
                the_StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                //打包文件存放目录
                the_StartInfo.WorkingDirectory = rarName;
                the_Process = new Process();
                the_Process.StartInfo = the_StartInfo;
                the_Process.Start();
                the_Process.WaitForExit();
                //if (the_Process.HasExited)
                //{
                //    flag = true;
                //}

                the_Process.Close();

            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            // return flag;
        }
开发者ID:dayuhan,项目名称:NETWORK,代码行数:65,代码来源:ZipHelper.cs

示例10: GetApplicationFileByExtension

 internal string GetApplicationFileByExtension(string ext) {
     reg_key = Registry.CurrentUser.OpenSubKey(
                         String.Format(@"Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\{0}\OpenWithList", ext));
     if (reg_key == null) return "";
     string mru_list = (string)reg_key.GetValue("MRUList");
     if (mru_list == null) return "";
     string app_file = (string)reg_key.GetValue(mru_list.Substring(0, 1));
     if (app_file.IndexOf("dmpm")>=0 && mru_list.Length>1) app_file=(string)reg_key.GetValue(mru_list.Substring(1,1));
     reg_key.Close();
     return app_file;
 }
开发者ID:hirokawaguchi,项目名称:docmaker.net,代码行数:11,代码来源:RegistryManager.cs

示例11: readValue

 public string[] readValue(string name)
 {
     try
     {
         regkey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(name, true);
     }
     catch (Exception e)
     {
         eventLog.WriteEntry("Cannot Open Registy Key " + e.Message);
         return null;
     }
     try
     {
         string[] s = (string[])regkey.GetValue("StringArray");
         regkey.Close();
         return s;
     }
     catch (Exception e)
     {
         eventLog.WriteEntry("Cannot Read Value " + e.Message);
         regkey.Close();
         return null;
     }
 }
开发者ID:shintaro,项目名称:Fake_iSCT_Service,代码行数:24,代码来源:MyRegKey.cs

示例12: unregisterProgram

 public bool unregisterProgram(string appName)
 {
     try
     {
         startupKey = Registry.CurrentUser.OpenSubKey(runKey, true);
         startupKey.DeleteValue(appName, true);
     }
     catch (Exception)
     {
         return false;
     }
     finally
     {
         startupKey.Close();
     }
     return true;
 }
开发者ID:RisingFog,项目名称:vibranceGUI,代码行数:17,代码来源:RegistryController.cs

示例13: deleteValue

 private static bool deleteValue(int Section, string Location, string Value)
 {
     key = getKeySection(Section);
     try
     {
         key = key.OpenSubKey(Location,true);
         key.DeleteValue(Value, false);
     }
     catch
     {
         return false;
     }
     finally
     {
         key.Close();
     }
     return true;
 }
开发者ID:sdasun,项目名称:KeyTouch,代码行数:18,代码来源:Startup.cs

示例14: setValue

 private static bool setValue(int Section, string Location, string Name, object Value)
 {
     key = getKey(Section);
     try
     {
         key = key.OpenSubKey(Location, true);
         key.SetValue(Name, Value);
     }
     catch
     {
         return false;
     }
     finally
     {
         key.Close();
     }
     return true;
 }
开发者ID:schultzisaiah,项目名称:just-gestures,代码行数:18,代码来源:RegistryEdit.cs

示例15: RegisterProgram

 public bool RegisterProgram(string appName, string pathToExe)
 {
     try
     {
         _startupKey = Registry.CurrentUser.OpenSubKey(RunKey, true);
         if (_startupKey == null)
             return false;
         _startupKey.SetValue(appName, pathToExe);
     }
     catch (Exception)
     {
         return false;
     }
     finally
     {
         _startupKey.Close();
     }
     return true;
 }
开发者ID:juvlarN,项目名称:vibranceGUI,代码行数:19,代码来源:RegistryController.cs


注:本文中的Microsoft.Win32.RegistryKey.Close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。