it is very simple.
You can check using IntPtr size. IntPtr sixe is 4 for 32 BIT OS and 8 for 64 BIT OS
if (IntPtr.Size == 8)
else
OR
Using intPtr and process we can search is OS64 bit. use the following code
[DllImport("kernel32.dll", SetLastError = true, CallingConvention = CallingConvention.Winapi)]
2 [return: MarshalAs(UnmanagedType.Bool)]
3 public static extern bool IsWow64Process([In] IntPtr hProcess, [Out] out bool lpSystemInfo);
4
5 public bool Is64Bit()
6 {
7 bool retVal;
8
9 IsWow64Process(Process.GetCurrentProcess().Handle, out retVal);
10
11 return retVal;