The code block that begins with the comment "Get the name of the element" does not make sense to me. If you get a listview element, why does the code specify the parameters of the element to be extracted, because if you already have values, you wonโt need to look for them.
After this comment, the first line indicates TreeView_GetItem (which, by the way, is actually an override of SendMessage), we want to get the text of the element and the associated lParam. The next line indicates the handle of the element about which we want information.
The next line indicates where the saved text should be saved, that is, in the szName buffer, which was allocated at the beginning of the function; the last line before calling the function determines the size of such a buffer, therefore, to avoid buffer overflow.
I suggest you look at the TreeView_GetItem and TVITEM documentation to better understand what is going on.
Secondly, next to the comment "original" is the source line of code that will be compiled using varning under the built-in visual C ++, but if you copy the same code in visual studio 2008, it will not compile. Since I did not write any of this code, and I'm trying to find out if it is possible that the author of the original was wrong on this line, since * pRoot should point to the HKEY type, but it goes over to the HTREEITEM type, which should never work with those then the data types do not match?
It is unclear what the code is trying to do there; at first glance, I would say that the lParam associated with each element in the root directory of the node tree stores a handle to the registry key, and the procedure receives it this way. However, if that were the case, then the action (HTREEITEM) would not make sense; it was probably a mistake forgiven by the compiler because it treated all the descriptors as plain void *; if my hypothesis is correct, you should keep the original string by simply replacing (HTREEITEM) with (HKEY).
source share