![]() |
| | #1 |
| Registered User Join Date: Mar 2005
Posts: 24
| c# OpenSubKey problem on 64 bit windows vs 32 bit. 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"))
{
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"))
{
Last edited by Striph; 03-19-2010 at 12:29 PM. |
| Striph is offline | |
| | #2 |
| Registered User Join Date: Mar 2005
Posts: 24
| I found the problem, my project was setup to compile for "Any CPU" which meant the program was being compiled as a 64 bit program which meant there was no registry reflection occuring. Once i changed the configuration options for the build to be x86 and set my code back to look in "Software\ImagePro" it started working again. |
| Striph is offline | |
| | #3 |
| eh ya hoser, got a beer? Join Date: Feb 2003
Posts: 323
| It will use the different registries for different Bit OS's.... But there is a simple way to check if you are on a 32 bit or 64 bit machine. Just create a bool method that checks IntPtr.Size and if its on a 32 bit system, it will be 4 bits, if it is on a 64 bit system, it will be 8. Read this: How to check whether the system is 32 bit or 64 bit ? Or just google it.
__________________ The keyboard is the standard device used to cause computer errors! |
| stumon is offline | |
| | #4 |
| Registered User Join Date: Mar 2005
Posts: 24
| Thanks for the link, yeah the boolean thing came to mind after i started posting, the post was initially on how to read just the wow3264node key but i branched out a bit. |
| Striph is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Porting from 32 bit machine to 64 bit machine! | anoopks | C Programming | 10 | 02-25-2005 08:02 PM |
| 32 bit v.s. 64 bit | xddxogm3 | Tech Board | 4 | 01-14-2005 09:58 AM |
| How to set an 32 bit allocation to 31 bit for address, 1 bit for flag? | franziss | C Programming | 7 | 12-10-2004 08:18 AM |
| If the RGB color is (64, 64, 255), change it to (64, 255, 64). | Grayson_Peddie | C# Programming | 2 | 06-14-2003 04:26 PM |
| Windows 98 problem | Hannwaas | A Brief History of Cprogramming.com | 16 | 12-30-2001 12:01 PM |