注册表的操作(C#)

注册表的操作:

得到系统的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();

 

附录:

VistaXP用户配置文件对照表

 

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

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值