On Fri, 7 Aug 2026 18:18:16 GMT, Phil Race <[email protected]> wrote: > I don't think this change is right. The key we use is one of the pre-defined > values HKEY hRootKey = HKEY_CURRENT_USER; > > as listed at > https://learn.microsoft.com/en-us/windows/win32/sysinfo/predefined-keys > > and those docs tell you > > > if hKey is a predefined key, then the system refreshes the predefined key, > > and phkResult receives the same hKey handle passed into the function. > > > If the key IS **NOT ONE OF** the predefined registry keys, call the > > [RegCloseKey](https://learn.microsoft.com/en-us/windows/desktop/api/winreg/nf-winreg-regclosekey) > > function after you have finished using the handle.
AFAIK, if you call with lpszSubKey **not NULL** and seems we do this `LONG lRet = ::RegOpenKeyExA(hRootKey, lpszSubKey, 0, KEY_ALL_ACCESS, &hKey);` this special rule for the predefined keys does not apply, and you have to call **RegCloseKey**. But I was thinking the same as you when reading the doc and I am still a bit unsure. If you want I can try to get some MS dev expert to comment. See also the doc https://learn.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regopenkeyexa `If the lpSubKey parameter is NULL or a pointer to an empty string, and if hKey is a predefined key, then the system refreshes the predefined key, and phkResult receives the same hKey handle passed into the function. Otherwise, phkResult receives a new handle to the opened key.` ------------- PR Comment: https://git.openjdk.org/jdk/pull/32249#issuecomment-5237469824
