RegSetValueEx silently fails to write to HKLM

前端 未结 1 1621
伪装坚强ぢ
伪装坚强ぢ 2021-01-27 14:27

I\'m trying to write in HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run from my C++ application like this:

HKEY key;
if (Reg         


        
相关标签:
1条回答
  • 2021-01-27 14:49

    The problem is that your application is subject to UAC registry virtualization. Because you did not include a manifest in your application, the system drops into an XP (!) compatibility mode. When you write to restricted parts of the registry under HKLM, the system re-directs them to what is known as the virtual store under HKCU.

    You should add a manifest to your application so that you are no longer virtualized. If you really do need to write to HKLM then you will need to specify the requireAdministrator option in the manifest so that your application is executed with elevated rights.

    Probably your next move is to take some time to read the documentation that I linked to above and be sure that you fully understand all the implications of UAC.

    0 讨论(0)
提交回复
热议问题