RegOpenKeyEx Question
-
Is there a way to test if a user has read or full access to certain registry entries? Will the return value of RegOpenKeyEx tell me this? Thanks!
-
Is there a way to test if a user has read or full access to certain registry entries? Will the return value of RegOpenKeyEx tell me this? Thanks!
Possible another way ..
if(ERROR_SUCCESS != RegOpenKeyEx(...)) { //Get the error code DWORD LastError = GetLastError(); //Get the error code as text (example) TCHAR szBuf[80]; LPVOID lpMsgBuf; FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf, 0, NULL ); sprintf(szBuf, "Error %d: %s", LastError, lpMsgBuf); MessageBox(NULL, szBuf, "Error", MB_OK); LocalFree(lpMsgBuf); }
HTH Frank -
-
Would you mind showing how to use this function? I'm using RegOpenKeyEX to get a handle to the key. Since RegGetKeySecurity requires a security descriptor, is there a way to get it from the handle? Thanks!
The RegGetKeySecurity function retrieves a copy of the security descriptor protecting the specified open registry key.
LONG RegGetKeySecurity(
HKEY hKey, // handle to key
SECURITY_INFORMATION SecurityInformation, // request
PSECURITY_DESCRIPTOR pSecurityDescriptor, // SD
LPDWORD lpcbSecurityDescriptor // buffer size
);Parameters
hKey
[in] Handle to an open key for which to retrieve the security descriptor.SecurityInformation
[in] Specifies a SECURITY_INFORMATION value that indicates therequested security information.
pSecurityDescriptor
[out] Pointer to a buffer thatreceives a copy of the requested security descriptor.
lpcbSecurityDescriptor
[in, out] Pointer to a variable that specifies the size, in bytes, of the buffer pointed to by the pSecurityDescriptor parameter. When the function returns, the variable contains the number of bytes written to the buffer.The above documentation clearly says how to do it. Did you look up the docs? Look at the statements marked in red.
Nibu thomas Software Developer Faqs by Michael dunn