32bit and 64bit

(how determine 64 bit operating system, process and client)

Class System.Environment (assembly: mscorlib) defines 2 static properties:
  • Environment.Is64BitOperatingSystem - determines whether the current operating system is a 64-bit operating system.
  • Environment.Is64BitProcess - determines whether the current process is a 64-bit process.

On a 32bit OS:
  • Oracle home's key registry resides in HKLM\Software\Oracle
On a 64bit OS:
  • 64bit Oracle client: Oracle home's key registry resides in HKLM\Software\Oracle
  • 32bit Oracle client: Oracle home's key registry resides in HKLM\Software\Wow6432Node\Oracle

Keep in mind, that 32bit process will not be able to access HKLM\Software\Oracle - it will transparently read HKLM\Software\Wow6432Node\Oracle instead. And that's the reason why on 64bit OS must be run an application built using target Any CPU or x64.

Such behaviour can be tested using the following code:

Console.WriteLine("Is 64bit process: {0}", Environment.Is64BitProcess);

Console.WriteLine(@"------ SOFTWARE\ORACLE");
RegistryKey key1 = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\ORACLE", false);
foreach (string s in key1.GetSubKeyNames())

Console.WriteLine(@"------ SOFTWARE\Wow6432Node\ORACLE");
RegistryKey key2 = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Wow6432Node\ORACLE", false);
foreach (string s in key2.GetSubKeyNames())

Using these info, steps to find out is Oracle client is 64bit can be defined as follows:

tags: Wow6432Node, C#, 64bit, x64, x86_64, RegistryKey

Last edited Jul 9, 2012 at 10:15 PM by alekseiv, version 7


No comments yet.