Saturday 30 April 2011

Reading registry from 64 bit application

I have been debugging one of my SL application developed in Win 7 VS2010 environment.  It was running fine in one of my colleague’s PC but it wasn’t working on my PC. That application was using a dll which does some cryptic work, I was able to locate the dll’s project and add it to SL solution so that I can debug into the project to see where it is failing. After some poking around, I found out that the program was reading HKLM\Software\Product key to get some data. I double checked my registry and the data exists so I ran again it still failed. The failure is not on reading the registry but the data from the registry which is used down the logic path. I double checked the key to make sure I am using the right key and it was right.

As would any normal programmer do next, I decided to change the value of the registry and see if it picks up the new value, to my surprise, the program did not pick up the new value.

With a couple of Google search I found out that, even if you pass the HKLM\Software\Product, when you run in 64 bit application, the program indeed was looking for HKLM\Software\Wow6432Node\Product. With that information, I changed the value in 64 bit registry entry and there is it, it picked up the correct value.

So just remember, if you are running a 64 bit application and even if you pass HKLM\Software\Product, the application will look for HKLM\Software\WOW6432Node.

0 comments:

Post a Comment