Check if the current user can write to the registry (C, windows)

Is there a way to check if the current user can write to the registry? More specifically, if he is not an administrator, he can write HKEY_LOCAL_MACHINE or policy keys to HKEY_CURRENT_USER.

I tried with LookupPrivilegeValue () , but I don't think it is correct.

Evaluated code.

+3
source share
1 answer

This is a simple and reliable way to find out if the user has access rights to the registry file: -

LONG err = RegOpenKeyEx(....,KEY_READ|KEY_WRITE);
if(err) {
  // Test err to see if its a permission error. if so, the user does not have permission.
+5
source

Source: https://habr.com/ru/post/1713788/


All Articles