|
Reported by Jon Oliver; checked by Jordan Russell
TRegistry.GetKeyNames returns a list of zero-lengthed strings.
Steps to Reproduce:
- Open a "troublesome" key--see below.
- Get the list of subkey names.
Why is this a bug: it's not legitimate for a subkey's name to be
blank.
What's the cause: a bug in ADVAPI32's RegQueryInfoKey function
What's a workaround: don't entirely trust RegQueryInfoKey's results
Version of Delphi: D5u1
OS: Windows 2000 sp2
I'm not sure if this qualifies as a Delphi bug, as it's inherited from
ADVAPI32.DLL.
At any rate, for some registry keys TRegistry.GetKeyNames will return
a list of zero-lengthed key names. The list has the proper count, but
lacks the text. This is a consequence of RegQueryInfoKey returning
zero for the maximum length of a key name.
If D5 takes a hit for this is, I suppose, a matter for debate. I can
find no microsoft document that addresses this behavior exactly--so
how would Boland's developers expect it? At any rate, you can work
around it somewhat, but distrusting RegQueryInfoKey's returns--there
are MS documents that suggest that at least.
Oddly enough, if you rename and rename back one of the troublesome
keys, it heals itself. This suggests to me that the key info values
(the troublesome one at least) are cached, rather than computed.
Here is a console app that searches your registry for "troublesome"
keys. |