I'm going to apply my psychic debugging powers, and guess that you have (a) a 64-bit operating system, and (b) Visual Studio 2010.
By default, when you create a new executable project in VS2010, it sets the project options to build for the x86 platform. (Previous versions of Visual Studio targeted "Any Platform", which would JIT to x86 code on a 32-bit OS, and x64 code on a 64-bit OS. But this caused other headaches, so they changed the default in VS2010.)
On a 64-bit OS, 32-bit apps have their own virtualized copy of HKLM\Software. MS did that for compatibility reasons, so that 32-bit apps wouldn't stomp on the settings of 64-bit apps. So when your 32-bit app goes looking for HKLM\Software, it's actually getting HKLM\Wow6432Node\Software.
Four easy fixes for this:
- Leave your application as 32-bit, but explicitly request the 64-bit Registry. This is probably the simplest solution.
- When you go into RegEdit, create your key under HKLM\Wow6432Node\Software instead.
- If you're creating the Registry key from an installer, use a 32-bit installer. Then it will write to what it sees as HKLM\Software, which is really HKLM\Wow6432Node\Software.
- Change your project options to target "Any Platform" (in Project Options > Build tab). Make sure to set it for both debug and release.