Home > Backend Development > C++ > How to Fix 'Requested registry access is not allowed' Errors in Windows When Modifying HKEY_CLASSES_ROOT?

How to Fix 'Requested registry access is not allowed' Errors in Windows When Modifying HKEY_CLASSES_ROOT?

Mary-Kate Olsen
Release: 2024-12-29 02:32:10
Original
207 people have browsed it

How to Fix

UAC Support for Registry Modifications

When performing registry modifications under the HKEY_CLASSES_ROOT hive in Windows versions beyond XP, such as Windows 7, Vista, and 2008, users may encounter the "Requested registry access is not allowed" error. This error stems from the introduction of User Account Control (UAC) in these operating systems, which enforces stricter security measures for system-level changes by requiring elevated privileges.

To ensure proper UAC support for registry modifications, it is necessary to add the following elements to your application manifest file (.manifest):

<?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>
      </security>
   </trustInfo>
</asmv1:assembly>
Copy after login

The section specifies the required execution level for your application, in this case, "requireAdministrator." This level indicates that the application needs to be run with administrative privileges to access protected registry keys.

By incorporating this manifest modification, your application will properly handle UAC elevation and allow you to make registry modifications under HKEY_CLASSES_ROOT in Windows versions with UAC enabled.

The above is the detailed content of How to Fix 'Requested registry access is not allowed' Errors in Windows When Modifying HKEY_CLASSES_ROOT?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template