注册表的操作(C#)
2009-04-21 11:12
459 查看
注册表的操作:
得到系统的AppData/Roaming文件夹路径,这个值在注册表里面存储着的。可以用下面这个方法得到。
GetValueData("Software//Microsoft//Windows//CurrentVersion//Explorer//Shell
Folders", "AppData");
下面这个是得到默认的Roaming文件夹
return
GetINIPath().Substring(0, 9) + "Default//AppData//Roaming";
写入特定类型的键值。
RegistryKey
reg = Registry.CurrentUser.CreateSubKey(strKey);
RegistryValueKind
rvk = reg.GetValueKind(strValue);
reg.SetValue(strValue, strData, rvk);
这个函数是指定写入值得类型。strType值是string dword,跟注册表里面的键值类型一样。
switch (strType)
{
case "string":
reg.SetValue(strValue, strData, RegistryValueKind.String);
break;
case "dword":
reg.SetValue(strValue, strData, RegistryValueKind.DWord);
break;
default:
break;
}
strKey是对应的目录,strValue是对应的键名
string
idVal = string.Empty;
RegistryKey
reg = Registry.CurrentUser.OpenSubKey(strKey);
idVal =
reg.GetValue(strValue).ToString();
附录:
Vista与XP用户配置文件对照表
得到系统的AppData/Roaming文件夹路径,这个值在注册表里面存储着的。可以用下面这个方法得到。
GetValueData("Software//Microsoft//Windows//CurrentVersion//Explorer//Shell
Folders", "AppData");
下面这个是得到默认的Roaming文件夹
return
GetINIPath().Substring(0, 9) + "Default//AppData//Roaming";
写入特定类型的键值。
RegistryKey
reg = Registry.CurrentUser.CreateSubKey(strKey);
RegistryValueKind
rvk = reg.GetValueKind(strValue);
reg.SetValue(strValue, strData, rvk);
这个函数是指定写入值得类型。strType值是string dword,跟注册表里面的键值类型一样。
switch (strType)
{
case "string":
reg.SetValue(strValue, strData, RegistryValueKind.String);
break;
case "dword":
reg.SetValue(strValue, strData, RegistryValueKind.DWord);
break;
default:
break;
}
strKey是对应的目录,strValue是对应的键名
string
idVal = string.Empty;
RegistryKey
reg = Registry.CurrentUser.OpenSubKey(strKey);
idVal =
reg.GetValue(strValue).ToString();
附录:
Vista与XP用户配置文件对照表
Vista新路径 | XP旧路径 |
.../AppData/Roaming | .../Application Data |
N/A | .../Local Settings |
.../AppData/Local | .../Local Settings/Application Data |
.../AppData/Local/Microsoft/Windows/History | .../Local Settings/History |
.../AppData/Local/Temp | .../Local Settings/Temp |
.../AppData/Local/Microsoft/Windows/Temporary Internet Files | .../Local Settings/Temporary Internet Files |
.../AppData/Roaming/Microsoft/Windows/Cookies | .../Cookies |
.../AppData/Roaming/Microsoft/Windows/Network Shortcuts | .../Nethood |
.../AppData/Roaming/Microsoft/Windows/Printer Shortcuts | .../PrintHood |
.../AppData/Roaming/Microsoft/Windows/Recent | .../Recent |
.../AppData/Roaming/Microsoft/Windows/Send To | .../SendTo |
.../AppData/Roaming/Microsoft/Windows/Start Menu | .../Start Menu |
.../AppData/Roaming/Microsoft/Windows/Templates | .../Templates |
.../Contacts | Not applicable |
.../Desktop | .../Desktop |
.../Documents | .../My Documents |
.../Downloads | Not applicable |
.../Favorites | .../Favorites |
.../Music | .../My Music |
.../Videos | .../My Videos |
.../Pictures | .../My Pictures |
.../Searches | Not applicable |
.../Links | Not applicable |
.../Saved Games | Not applicable |
相关文章推荐
- C#中对注册表的操作(原创)
- C#操作注册表
- 解决C#操作注册表权限不够的问题
- c#操作进程、服务、注册表(源码测试通过)
- c# RegistryKey操作注册表
- c#中对注册表的操作_c#应用
- C#操作windows注册表的方法
- C#对注册表的操作
- C#中对注册表的操作
- C# 软件随机启动 --- 注册表操作
- c#对注册表的操作
- c# 注册表操作,创建,删除,修改,判断节点是否存在
- C#操作注册表
- [转]C#操作注册表
- 如何在C#中轻松操作注册表
- 如何在C#中轻松操作注册表
- C# 操作注册表 写入注册表 修改注册表 读取注册表
- C#操作注册表全攻略(转)
- C#中对注册表的操作
- C# 操作注册表