Yes, you are right we get actual error "Access denied" from RegConnectRegistry itself, but in some cases the GetLastError() is useful.
For e.g. If wrong credentials are given to RegConnectRegistry then it returns Access Denied and GetLastError() returns the actual reason for access denied
"Logon Failure: unknown user name or bad password"
But, may not be true in every case...
SandyG
Last edited by SandyG; February 23rd, 2012 at 09:11 AM.
Yes, you are right we get actual error "Access denied" from RegConnectRegistry itself, but in some cases the GetLastError() is useful.
For e.g. If wrong credentials are given to RegConnectRegistry then it returns Access Denied and GetLastError() returns the actual reason for access denied
"Logon Failure: unknown user name or bad password"
Possible, last error has been set by a previously called function in your code or by a function internally called by RegConnectRegistry.
Anyway, as long as it's not clearly documented, avoid this type of workaround.
Reasons in order of their probability:
1. Remote access to registry is restricted by remote host policy
2. The accessed key has specific access settings the domain account not in, or explicitly denied
3. Some network resource (share or printer) on the remote target is already connected, with different account credentials (not sure, but it's worth to check)
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.