日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程语言 > C# >内容正文

C#

C#-注册表操作

發(fā)布時(shí)間:2025/6/17 C# 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 C#-注册表操作 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
using System; using System.Collections.Generic; using System.Text; using Microsoft.Win32; //對(duì)注冊(cè)表操作 using System.Collections; //使用Arraylist using System.Security.Cryptography;//加密解密 using System.IO; //文件操作 using System.Runtime.InteropServices;//調(diào)用DLL DllImport using System.Management; //獲取硬件信息 using System.Net; //獲取IP地址是用到 using System.Drawing; //image using System.Net.NetworkInformation; //ping 用到 using System.Text.RegularExpressions; //正則 using System.Data; using System.Data.SqlClient; using Microsoft.VisualBasic; //簡(jiǎn)體轉(zhuǎn)繁體時(shí)用到 using System.Web; //html UrlEncode//注冊(cè)表操作public class GF_RegReadWrite{/// <summary>/// 讀取路徑為keypath,鍵名為keyname的注冊(cè)表鍵值,缺省返回def/// </summary>/// <param name="rootkey"></param>/// <param name="keypath">路徑</param>/// <param name="keyname">鍵名</param>/// <param name="rtn">默認(rèn)為null</param>/// <returns></returns> static public bool GetRegVal(RegistryKey rootkey, string keypath, string keyname, out string rtn){rtn = "";try{RegistryKey key = rootkey.OpenSubKey(keypath);rtn = key.GetValue(keyname).ToString();key.Close();return true;}catch{return false;}}/// <summary>/// 設(shè)置路徑為keypath,鍵名為keyname的注冊(cè)表鍵值為keyval/// </summary>/// <param name="rootkey"></param>/// <param name="keypath"></param>/// <param name="keyname"></param>/// <param name="keyval"></param>/// <returns></returns>static public bool SetRegVal(RegistryKey rootkey, string keypath, string keyname, string keyval){try{RegistryKey key = rootkey.OpenSubKey(keypath, true);if (key == null)key = rootkey.CreateSubKey(keypath);key.SetValue(keyname, (object)keyval);key.Close();return true;}catch{return false;}}/// 創(chuàng)建路徑為keypath的鍵private RegistryKey CreateRegKey(RegistryKey rootkey, string keypath){try{return rootkey.CreateSubKey(keypath);}catch{return null;}}/// 刪除路徑為keypath的子項(xiàng)private bool DelRegSubKey(RegistryKey rootkey, string keypath){try{rootkey.DeleteSubKey(keypath);return true;}catch{return false;}}/// 刪除路徑為keypath的子項(xiàng)及其附屬子項(xiàng)private bool DelRegSubKeyTree(RegistryKey rootkey, string keypath){try{rootkey.DeleteSubKeyTree(keypath);return true;}catch{return false;}}/// 刪除路徑為keypath下鍵名為keyname的鍵值private bool DelRegKeyVal(RegistryKey rootkey, string keypath, string keyname){try{RegistryKey key = rootkey.OpenSubKey(keypath, true);key.DeleteValue(keyname);return true;}catch{return false;}}}

總結(jié)

以上是生活随笔為你收集整理的C#-注册表操作的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。