I currently have a C# form app that reads a registry setting to find the location of a path, and then once it finds that it does its thing. I designed everything on a 32-bit OS and it worked flawlessly. I just got a new system running Windows 7 64-bit and have run into a problem.
The program its looking for normally installs into the following registry key:
HKLM\Software\ImagePro
So i have my code setup like this:
Code:
if ((key = key.OpenSubKey("SOFTWARE\\ImagePro\\Current")) != null)
{
string exePath = (string)key.GetValue("BinPath");
if (File.Exists(exePath + "\\convert.exe"))
{
And it runs on a 32-bit OS just fine. I've found that on a 64-bit OS it no longer stores that registry info in the root Software tree, so when I run my program i have it setup to notify me that the ImagePro software is not installed, which since it can't find it is true, but it is installed. I've found that the registry now does this for 32 bit programs:
HKLML\SOFTWARE\Wow6432Node\ImagePro
Apparently all 32 bit registrys are in this "64 bit hive" branch of the Software registry keys.
So I've changed my code to do this below and it now works on my 64-bit os.
Code:
if ((key = key.OpenSubKey("SOFTWARE\\Wow6432Node\\ImagePro\\Current")) != null)
{
string exePath = (string)key.GetValue("BinPath");
if (File.Exists(exePath + "\\convert.exe"))
{
Right now I have it hardcoded to just do the 64 bit key. Is there a way to read if an OS is 64 bit vs 32 bit? Or should I just read in the 64 bit registry key first, and if it fails, read in the 32 bit registry key? I've read that a 32-bit app is supposed to automatically read the Wow6432node entries on a 64bit OS, but its not so I'm lost right now. Anyone have any ideas or thoughts?