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.

4

3 回答 3

2

这应该可以为您提供所需的内容:

 string platform = IntPtr.Size == 4 ? "x86" : "x64";
于 2013-07-17T21:18:10.957 回答
0

Environment.Is64BitProcess应该做的伎俩

于 2013-07-17T21:27:38.157 回答
0

您可以使用 IntPtr.Size

string foobar = String.Empty;

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

也可以看看:

如何使用 .NET 检测 Windows 64 位平台?

选择的答案非常好。

于 2013-07-17T21:23:39.713 回答