You are getting the exception because the factory method couldn't find the sub key at the specified location and returned null
.
Despite your sub key address being perfectly valid, because you are using Registry.LocalMachine.OpenSubKey
you are essentially specifying HKEY_LOCAL_MACHINE
in the sub key address twice. The solution is to change your sub-key path to:
SYSTEM\ControlSet001\Control\Class{4D36E972-E325-11CE-BFC1-08002BE10318}\0011
You may also want to consider a more robust approach:
using (RegistryKey myKey =
Registry.LocalMachine.OpenSubKey(
@"SYSTEM\ControlSet001\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}\0011", true))
{
if (myKey != null)
{
Console.WriteLine((string) myKey.GetValue("NetworkAddress"));
myKey.SetValue("NetworkAddress", "002408B2A2D2", RegistryValueKind.String);
}
}