當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。