自己的程序写入到注册表后,获取不到值,重启后也不行,但是获取同目录下360Safe项就可以获取到。
写注册表的程序的目标平台(x86/x64的那个)和当前这个获取注册表信息的程序目标平台不一致导致。改用RegistryKey.OpenBaseKey方法获取LocalMachine。如下:
RegistryKey advanced = null; RegistryKey LM32 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32); advanced = LM32.OpenSubKey(_advancedPath); RegistryKey LM64 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64); advanced = LM64.OpenSubKey(_advancedPath);
感谢这个大佬的回答C#利用Registry和RegistryKey获取不到自己设置注册表Local_Machine里的值_博问_博客园 (cnblogs.com)
但是还是不明白在哪里去看我写的注册项是属于32位还是64位
标签:有项,RegistryKey,注册表,获取,LocalMachine,OpenBaseKey,advanced From: https://www.cnblogs.com/bklsj/p/18082480