digitalmars.D.learn - Read registry keys recursively
- TheDGuy (19/19) May 29 2016 Hello,
- Era Scarecrow (7/27) May 29 2016 Well this was a fun thing to figure out. Geez...
- Era Scarecrow (5/7) May 29 2016 this just occurred to me i tried to keep to the example but i
Hello, i am wondering what is wrong with my code: import std.windows.registry; import std.stdio; void main(){ Key lclM = Registry.localMachine(); Key hrdw = lclM.getKey("HARDWARE"); writeRegistryKeys(hrdw); } void writeRegistryKeys(Key k){ foreach(Key key; k.keys){ writeRegistryKeys(key.getKey(key.name())); } writeln(k.name()); } i get: std.windows.registry.RegistryException std\windows\registry.d(511): Failed to open requested key: "ACPI" Even though there is a key called 'ACPI' under localmachine/hardware?
May 29 2016
On Sunday, 29 May 2016 at 15:48:49 UTC, TheDGuy wrote:Hello, i am wondering what is wrong with my code: import std.windows.registry; import std.stdio; void main(){ Key lclM = Registry.localMachine(); Key hrdw = lclM.getKey("HARDWARE"); writeRegistryKeys(hrdw); } void writeRegistryKeys(Key k){ foreach(Key key; k.keys){ writeRegistryKeys(key.getKey(key.name())); } writeln(k.name()); } i get: std.windows.registry.RegistryException std\windows\registry.d(511): Failed to open requested key: "ACPI" Even though there is a key called 'ACPI' under localmachine/hardware?Well this was a fun thing to figure out. Geez... You have everything good except for one line.writeRegistryKeys(key.getKey(key.name()));Let's translate that. Assume key = ACPI... SO... ACPI.getkey("ACPI") you should see the problem. Here's the correct line! writeRegistryKeys(k.getKey(key.name()));
May 29 2016
On Sunday, 29 May 2016 at 16:46:34 UTC, Era Scarecrow wrote:you should see the problem. Here's the correct line! writeRegistryKeys(k.getKey(key.name()));this just occurred to me i tried to keep to the example but i shouldn't have. Since you already have the inner key, just pass that and it works. Far more obvious what's going on now. writeRegistryKeys(key);
May 29 2016