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.
Regards, Michael Karcher