简体   繁体   English

如何在Windows 7操作系统中获得没有管理员权限的注册表项

[英]how to get registry key without having administrator rights in windows 7 OS

In my application(windows C#.net) i am trying to get the registry key. 在我的应用程序(Windows C#.net)中,我试图获取注册表项。 In windows XP(with and without admin rights) it is working fine and in windows 7 with admin rights it is working fine. 在Windows XP(有和没有管理员权限)它工作正常,在Windows 7与管理员权限,它工作正常。 But in windows 7 without admin rights when i try to get the registry key, the aplication is getting crash. 但是在我尝试获取注册表项时没有管理员权限的Windows 7中,应用程序正在崩溃。

I am using the following code to get the registry key 我使用以下代码来获取注册表项

Microsoft.Win32.RegistryKey rgKey = Microsoft.Win32.Registry.LocalMachine.CreateSubKey(rgPath); Microsoft.Win32.RegistryKey rgKey = Microsoft.Win32.Registry.LocalMachine.CreateSubKey(rgPath);

Can some help to get the registry key without admin rights in windows 7. 有些帮助可以在Windows 7中获得没有管理员权限的注册表项。

Thanks in Advance. 提前致谢。

It could not be done in Windows7 without admin rights. 没有管理员权限,无法在Windows7中完成。

Here is the solution for it. 这是它的解决方案。

Open the project and go to proejct menu and select add new item. 打开项目并转到proejct菜单并选择添加新项目。 There will be an item with the name "Application Manifest File". 将有一个名为“Application Manifest File”的项目。 Add this to your project. 将其添加到您的项目中。 A file looking like xml will be opened. 将打开一个看起来像xml的文件。

Search for the following line in that file. 在该文件中搜索以下行。

<requestedExecutionLevel level="asInvoker" uiAccess="false" />

and replace it with this line 并用这条线替换它

<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />

Save the file and rebuild the solution. 保存文件并重建解决方案。 Now your software will ask for the administrator rights each time before executing on Windows7. 现在,您的软件每次在Windows7上执行之前都会要求管理员权限。

Enjoy :) 请享用 :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM