![](/img/trans.png)
[英]How to start remote registry services on windows 10 from a remote machine using c#/vb
[英]C# Access Remote Registry with Windows 10 not work
我使用此代碼在遠程計算機上獲取已安裝的.NET版本。 在Windows 7上可以完美運行,但在Windows 10上會引發以下異常
System.Security.SecurityException:不允許請求的注冊表訪問。
代碼示例
using (RegistryKey remoteHklm = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, hostName))
{
using (RegistryKey serviceKey = remoteHklm.OpenSubKey(@"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full", true))
{
if (serviceKey != null)
{
version = serviceKey.GetValue("Version").ToString();
}
else
{
version = "error on get version from registry";
}
}
}
您使用Windows 10對該注冊表項沒有寫訪問權限。 將第二個OpenSubKey
參數更改為false
,可以在注冊表編輯器中檢查密鑰的權限。
using (RegistryKey serviceKey = remoteHklm.OpenSubKey(@"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full", false))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.