开发者

Access to HKLM registry branch on Win 7 from within application

开发者 https://www.devze.com 2023-01-05 00:41 出处:网络
Is it possible to write to the HKLM registry branch in Win 7 from an application? My existing code is not able to write to the HKLM registry branch on Win 7 machines, while it is able to do this on X

Is it possible to write to the HKLM registry branch in Win 7 from an application?

My existing code is not able to write to the HKLM registry branch on Win 7 machines, while it is able to do this on XP machines.开发者_StackOverflow中文版

How do you allow an application read/write access to HKLM on Win 7, or should all applications now just use HKCU instead? What if I need to store settings on a machine basis rather than a user basis?


You need to decide whether you are writing an administrative app, that deliberately changes settings for all users (by writing to HKLM) or an ordinary app, that does not. If you really are writing an administrative app then put a manifest on it that has a requestedExecutionLevel of requireAdministrator. The user will get a UAC prompt every time they run the app, but your writes to HKLM will succeed. Alternatively, change the app to write to HKCU or some other per-user store.

(No idea how to add a manifest? Tell me what language/IDE you're using and I'll try to help.)

Relying on virtualization is a bad idea. It was implemented to let unmanifested applications at least sorta kinda work. It will go away some day and is not that great while it's here.


Win 7 uses Registry Virtualization

Read the article and look into (HKEY_USERS\<User SID>_Classes\VirtualStore\Machine\Software).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号