T
2019-12-29 01:11:39 UTC
Hi All,
Questions on reading registry keys with calls to Kernel32.dll:
References:
https://docs.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regopenkeyexw
https://docs.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regclosekey
https://docs.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regqueryvalueexw
I am trying to read the value of this key:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System]
"EnableLUA"=dword:00000000
https://docs.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regopenkeyexw
https://docs.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regclosekey
https://docs.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regqueryvalueexw
Am I correct that to read a registry key, you must
1) open the key,
2) read the value,
3) close the key?
In these calls, are the pointers 32 bit or 64 bit depending on the
version of Windows?
To open the key, I must call
LSTATUS RegOpenKeyExW(
HKEY hKey,
LPCWSTR lpSubKey,
DWORD ulOptions,
REGSAM samDesired,
PHKEY phkResult
);
1) Is hKey is the handle of the key I just opened? And I need to keep
track of (save) it.
2) Is this the same hKey used in RegQueryValueExW and RegCloseKey?
LSTATUS RegQueryValueExW(
HKEY hKey,
LPCWSTR lpValueName,
LPDWORD lpReserved,
LPDWORD lpType,
LPBYTE lpData,
LPDWORD lpcbData
);
LSTATUS RegCloseKey(
HKEY hKey
);
what is “lpSubKey”?
1) is “lpSubKey”
\Microsoft\Windows\CurrentVersion\Policies\System
or
\Microsoft\Windows\CurrentVersion\Policies\System\EnableLUA
or something else?
2) forward slashes or back slashes?
3) does it use a starting slash?
4) does it use an ending slash?
RegQueryValueExW
1) what is lpSubKey?
EnableLUA
or
\Microsoft\Windows\CurrentVersion\Policies\System\EnableLUA
or something else
Many thanks,
-T
Questions on reading registry keys with calls to Kernel32.dll:
References:
https://docs.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regopenkeyexw
https://docs.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regclosekey
https://docs.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regqueryvalueexw
I am trying to read the value of this key:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System]
"EnableLUA"=dword:00000000
https://docs.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regopenkeyexw
https://docs.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regclosekey
https://docs.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regqueryvalueexw
Am I correct that to read a registry key, you must
1) open the key,
2) read the value,
3) close the key?
In these calls, are the pointers 32 bit or 64 bit depending on the
version of Windows?
To open the key, I must call
LSTATUS RegOpenKeyExW(
HKEY hKey,
LPCWSTR lpSubKey,
DWORD ulOptions,
REGSAM samDesired,
PHKEY phkResult
);
1) Is hKey is the handle of the key I just opened? And I need to keep
track of (save) it.
2) Is this the same hKey used in RegQueryValueExW and RegCloseKey?
LSTATUS RegQueryValueExW(
HKEY hKey,
LPCWSTR lpValueName,
LPDWORD lpReserved,
LPDWORD lpType,
LPBYTE lpData,
LPDWORD lpcbData
);
LSTATUS RegCloseKey(
HKEY hKey
);
what is “lpSubKey”?
1) is “lpSubKey”
\Microsoft\Windows\CurrentVersion\Policies\System
or
\Microsoft\Windows\CurrentVersion\Policies\System\EnableLUA
or something else?
2) forward slashes or back slashes?
3) does it use a starting slash?
4) does it use an ending slash?
RegQueryValueExW
1) what is lpSubKey?
EnableLUA
or
\Microsoft\Windows\CurrentVersion\Policies\System\EnableLUA
or something else
Many thanks,
-T