简体   繁体   中英

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. On current versions of Windows this could mean either Itanuim or x64.

Your process won't necessarily be 64 bit even on a 64 bit machine/OS.

Othewise Microsoft.Build.Utilities.ProcessorArchitecture.CurrentProcessArchitecture returns a string with the current proc arch. It's in 3.5.

How about if I have an x64 and an x86 binary dependency on a console application.

Is there a way of deciding at runtime which reference is used dependant on whether we are running on x64 or x86?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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