regedit: Implement open last key at startup [try 3]

Paul Vriens at
Thu Jul 2 08:40:05 CDT 2009

Michael Karcher wrote:
> Am Donnerstag, den 02.07.2009, 17:42 +0500 schrieb Vladimir Pankratov:
>> Implement open last key at startup.
> Why do you use wszKey in the get code path, but wszVal in the set code
> path? But before you change that, read on:
> +static void get_set_last_key(HWND hwndTV, BOOL bget)
> This looks to me like the "boolean parameter to change behaviour"
> antipattern. I think you did it to avoid duplication of the wsz...
> constants for the registry path and the key name. Make them global
> variables (still static, so file local), and make two functions out of
> it. Open the key only for READ access if you want to load.
> Why do you copy the result of GetItemFullPath? Why don't you free the
> result of GetItemFullPath?
> Finally, I think Paul Vriens was wrong on omitting the RegCloseKey.
> While you really don't have to close predefined keys like
> HKEY_CURRENT_USER, you do have to close HKCU\Software\Microsoft\Windows
> \CurrentVersion\Applets\Regedit.

So, does the RegCloseKey only have to be done in the set/create case?

I mean while reading MSDN (yeah, I know) it states:

"If the key is not one of the predefined registry keys, call the 
RegCloseKey function after you have finished using the handle."

But as the subkey can't be NULL (again, MSDN) we will never have a 
predefined one.

> Regards,
>   Michael Karcher



More information about the wine-devel mailing list