I spent a good few hours yesterday trying to figure out why my code to extract the Windows key from the registry was not working. The key was there but the code would not read it! It was infuriating.
After taking a little time to sit back and think about the problem – it dawned upon me. I am using a 64-bit operating system. This means that although the key appeared to be present in the location I was checking, it may indeed have been under the WOW64 part. After digging there it was.
With only a few modifications to my code, it now works successfully. I am quite pleased that Microsoft added a method to the register editing features in .NET framework 4 and for those who are interested I used the OpenBaseKey method of the RegistryKey class with the RegistryView attribute set depending on if the operating system is 64-bit or not.
The code now works perfectly. Let that be a lesson to you – focusing on answers to simple problems gets you nowhere fast!