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()));

Reply via email to