Reputation: 5272
I want to modify the registry value at run time in an application and should make sure that user has permission to do that.
Is it possible to check if the user has permission to write into registry before editing the registry values?
Upvotes: 1
Views: 689
Reputation: 613461
This is certainly possible using the AccessCheck Win32 API. However, it's not very easy to implement. You'll find many examples online and you'll soon discover that Windows security is tricky.
On the other hand it is trivially easy to attempt to write a value and check for ERROR_ACCESS_DENIED. That is the recommended way to deal with access rights.
Note that you typically do not need to modify a value to ascertain whether or not the user has sufficient rights. Generally it suffices to attempt to open the containing key for writing. If that fails, you won't be able to modify the value.
Upvotes: 6