访问注册表和Windows 10版本1709, [英] Access to Registry and Windows 10 version 1709,

查看:85
本文介绍了访问注册表和Windows 10版本1709,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我们有一个用C#编写的exe,它试图访问

we have an exe written in C# which tries to access some keys under

HKEY_USERS \ .DEFAULT \\ \\软件\

HKEY_USERS\.DEFAULT\Software\

在Windows 10版本1703之前没有问题。

Until Windows 10 version 1703 there wasn't a Problem.

但在更新到Windows 10版本1709之后,抛出SecuzrityException。

But after updating to  Windows 10 version 1709, a SecuzrityException is thrown.

这是使用过的清单

<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <assemblyIdentity version="1.0.0.0" name="MyApplication.app" />
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
	  <security>
		  <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
			  <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
		  </requestedPrivileges>
		  <applicationRequestMinimum>
			  <defaultAssemblyRequest permissionSetReference="Custom" />
			  <PermissionSet class="System.Security.PermissionSet" version="1" ID="Custom" SameSite="site" Unrestricted="true" />
		  </applicationRequestMinimum>
	  </security>
  </trustInfo>
  
  <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
    <application>
      <!-- A list of all Windows versions that this application is designed to work with. Windows will automatically select the most compatible environment.-->
      <!-- If your application is designed to work with Windows 7, uncomment the following supportedOS node-->
      <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
    </application>
  </compatibility>
  
  <!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
  <!-- <dependency>
    <dependentAssembly>
      <assemblyIdentity
          type="win32"
          name="Microsoft.Windows.Common-Controls"
          version="7.1.0.0"
          processorArchitecture="*"
          publicKeyToken="6595b64144ccf1df"
          language="*"
        />
    </dependentAssembly>
  </dependency>-->

</asmv1:assembly>

可执行文件本身称为starter.exe。

The executable itself is called starter.exe.

如何更改清单以避免此SecuzrityException?

How must I change the manifest to avoid this SecuzrityException ?

tia

  Hendrik Schmieder

  Hendrik Schmieder

推荐答案

Hello Hendrik,

Hello Hendrik,

如何访问"HKEY_USERS \.DEFAULT"下的密钥Software\"在C#? 我在Windows 10下测试以下代码,版本是1709,它在我这边很好。

How do you access the key under "HKEY_USERS\.DEFAULT\Software\" in C#?  I test the following code under windows 10 which version is 1709 and it works well on my side.

            //set value in registy
            RegistryKey key = Registry.Users;
            RegistryKey software = key.OpenSubKey(".DEFAULT\\Software\\RegisteredApplications", true);
            software.SetValue("TTTTTT","eeeeeeee");
            key.Close();


            //get value in registy
            RegistryKey key1 = Registry.Users;
            RegistryKey software1 = key.OpenSubKey(".DEFAULT\\Software\\RegisteredApplications", true);
            var value=software1.GetValue("TTTTTT");
            Console.WriteLine(value);
            key1.Close();

我的操作系统版本

我还试试你的清单在我的程序中,一切都很好。在清单中,您需要以管理员权限运行程序。我有一个混乱,为什么你不评论"支持的OS节点"这表明您的程序使用Windows 7工作

And I also try your manifest in my program and everything is ok. In your manifest you require to run the program under admin privileges. And I have a litter confused that why your not comment "supportedOS node" that indicates your program works with windows 7.

如果您有任何问题,请随时与我联系。

If you have any issues please feel free to contact me.

此致,

Neil Hu


这篇关于访问注册表和Windows 10版本1709,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆