0
搜索了很長時間後,我一直無法解決此問題。我試圖在Windows 7中創建一個註冊表項。我有UAC關閉,並已在註冊表中更改權限和所有者,但我仍然遇到Access拒絕錯誤。我粘貼了下面的代碼。我試了幾個(甚至是微軟的)解決方案都無濟於事。任何幫助感謝!創建註冊表項的問題
Dim rs As RegistrySecurity = New RegistrySecurity()
rs.AddAccessRule(New RegistryAccessRule(user, RegistryRights.FullControl, InheritanceFlags.ContainerInherit Or InheritanceFlags.ObjectInherit, PropagationFlags.InheritOnly, AccessControlType.Allow))
Dim subkey As String = "software\HSC\Extractor 3"
Dim regkey As RegistryKey = LocalMachine.CreateSubKey(subkey, RegistryKeyPermissionCheck.ReadWriteSubTree, RegistryOptions.Volatile,rs)
rs.AddAccessRule(New RegistryAccessRule(user, RegistryRights.FullControl, InheritanceFlags.ContainerInherit Or InheritanceFlags.ObjectInherit, PropagationFlags.InheritOnly, AccessControlType.Allow))
regkey.SetAccessControl(rs)
regkey = LocalMachine.OpenSubKey(subkey, RegistryKeyPermissionCheck.ReadWriteSubTree, RegistryRights.FullControl)
rs.SetOwner(New NTAccount(user))