使用注册表 [英] using registry
本文介绍了使用注册表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好
我需要在
中添加注册密钥
HKEY_CURRENT_USER \ Software \ Microsoft \ Windows \ CurrentVersion \ Policies
\ Explorer
使用
registerykey subkey = registery.open(keypath);
但是当我在C#中执行此操作时,出现了我需要先决条件的错误
那么如何在任何计算机上授予我的应用程序管理员权限?
感谢
hi every one
i need to add registery key in
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies
\Explorer
using
registerykey subkey= registery.open(keypath);
but when i did that in c# i had error that i need premission
so how can i give my application administrator rights in any computer??
thanks
推荐答案
这里是MSDN链接,希望对您有所帮助:
http://msdn.microsoft.com/en-us/library/system. security.permissions.registrypermission.aspx [ ^ ]
Here is an MSDN Link, hope it helps:
http://msdn.microsoft.com/en-us/library/system.security.permissions.registrypermission.aspx[^]
您可以设置清单文件来请求此类权限,但是这会产生警告,提示人们可能选择拒绝而不是运行您的应用.您可以要求它们以管理员身份运行,这也存在相同的问题.
You can set up your manifest file to request such permissions, but that will generate a warning that people may choose to reject, and not run your app. You can ask them to run as admin, which has the same problem.
使用Microsoft.Win32;
RegistryKey rKey = Registry.currentuser.OpenSubKey("\ Software \ Microsoft \ Windows \ CurrentVersion \ Policies
\ Explorer);
如果(rKey == null)
{
rKey = Registry.currentuser.CreateSubKey("\ Software \ Microsoft \ Windows \ CurrentVersion \ Policies
\ Explorer);
}
RegistryKey键= Registry.currentuser.OpenSubKey("\ Software \ Microsoft \ Windows \ CurrentVersion \ Policies
\ Explorer,正确);
字符串sysname = Environment.MachineName;
key.SetValue("Sysname",sysname,RegistryValueKind.String);
问候
S.Murugesan
Mr.s.murugesan@gmail.com
using Microsoft.Win32;
RegistryKey rKey = Registry.currentuser.OpenSubKey("\Software\Microsoft\Windows\CurrentVersion\Policies
\Explorer");
if (rKey == null)
{
rKey = Registry.currentuser.CreateSubKey("\Software\Microsoft\Windows\CurrentVersion\Policies
\Explorer");
}
RegistryKey key = Registry.currentuser.OpenSubKey("\Software\Microsoft\Windows\CurrentVersion\Policies
\Explorer", true);
string sysname = Environment.MachineName;
key.SetValue("Sysname", sysname, RegistryValueKind.String);
Regards
S.Murugesan
Mr.s.murugesan@gmail.com
这篇关于使用注册表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文