简体   繁体   English

如何在.NET中告诉您是在x86还是x64上运行?

[英]How to tell in .NET whether you are running on x86 or x64?

在.NET(3.5或更低版本)中是否有办法判断控制台应用程序是在x86还是x64上运行?

IntPtr.Size == 8 // 64bit

如果你不介意使用interop,这个函数会有所帮助: IsWow64Process例子

Do you mean the machine or the process? 你的意思是机器还是过程? Why do you want to know? 你为什么想知道?

Aku's answer will tell you if the process you are in is running in a 64bit mode. Aku的答案将告诉您您所处的进程是否以64位模式运行。 On current versions of Windows this could mean either Itanuim or x64. 在当前版本的Windows上,这可能意味着Itanuim或x64。

Your process won't necessarily be 64 bit even on a 64 bit machine/OS. 即使在64位计算机/操作系统上,您的进程也不一定是64位。

Othewise Microsoft.Build.Utilities.ProcessorArchitecture.CurrentProcessArchitecture returns a string with the current proc arch. Othewise Microsoft.Build.Utilities.ProcessorArchitecture.CurrentProcessArchitecture返回一个包含当前proc arch的字符串。 It's in 3.5. 它在3.5。

How about if I have an x64 and an x86 binary dependency on a console application. 如果我在控制台应用程序上有x64和x86二进制依赖关系怎么样?

Is there a way of deciding at runtime which reference is used dependant on whether we are running on x64 or x86? 有没有办法在运行时决定使用哪个引用取决于我们是在x64还是x86上运行?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM