简体   繁体   中英

Find out process bitness programmatically [duplicate]

Is there anyway I can find out if my .NET process is running as 32bit process or 64bit process?

You probably want Environment.Is64BitProcess if you're using .NET 4.0 or later. Otherwise, check IntPtr.Size , as suggested in the other answers.

if (IntPtr.Size == 4)
    // 32-bit

else if (IntPtr.Size == 8)
    // 64-bit

From this question

However, as pointed by @Jim Mischel, on .NET 4 and above, you should use

Environment.Is64BitProcess

Use IntPtr.Size property to find out process bitness.

if(IntPtr.Size == 4)
 // 32 bit process
else
 // 64bit process

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