1

Title is clear: how can I change a value in C# depending on destination architecture? In particular, I want to change a string depending on x86 or x64. Many Thanks!

Edit: I need to check if an x64 Office version is installed if my application is x64 too.

3 Answers3

2

This should get you what you're looking for:

 string platform = IntPtr.Size == 4 ? "x86" : "x64";
It'sNotALie.
  • 22,289
  • 12
  • 68
  • 103
0

You can use IntPtr.Size

string foobar = String.Empty;

if (IntPtr.Size == 4) //32-bit
    foobar = "foo";
else if (IntPtr.Size == 8) //64-bit
    foobar = "bar";

see also:

How to detect Windows 64-bit platform with .NET?

The answer chosen is pretty darn good.

Community
  • 1
  • 1
broguyman
  • 1,386
  • 4
  • 19
  • 36
0

Environment.Is64BitProcess should do the trick

Sriram Sakthivel
  • 72,067
  • 7
  • 111
  • 189