办法对注册表位置写 [英] Way to write on registry location
本文介绍了办法对注册表位置写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在C#窗口application.I工作想写registry.i知道如何写上registry.I用波纹管语法对注册表写入。
work on C# window application.I want to write on registry.i know how to write on registry.I use bellow syntax to write on registry.
Microsoft.Win32.RegistryKey key;
key = Microsoft.Win32.Registry.CurrentUser.cre.CreateSubKey("asb");
key.SetValue("asb", "Isabella");
key.Close();
但问题是,我无法在指定位置书写。我想在波纹管的位置写
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
在这个位置要添加字符串值=ABC和 ValueData =EFD
如果有任何疑问PLZ ask.thanks提前。
On this location want to add string value="abc" and ValueData="efd" If have any query plz ask.thanks in advance.
推荐答案
有关HKCU:
string keyName = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Run";
RegistryKey rk = Registry.CurrentUser.OpenSubKey(keyName, true);
rk.SetValue("abc", "efd");
rk.Close();
有关HKLM你需要管理员权限才能做到这一点。这需要增加一个清单给你的程序执行在Vista或Win7的UAC提示。
For HKLM you need to do it with administrative privileges. That requires adding a manifest to your program to invoke the UAC prompt on Vista or Win7.
这篇关于办法对注册表位置写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文