如何判断我的应用程序是作为 32 位还是 64 位应用程序运行?
问题描述:
如何判断我的应用程序(在 Visual Studio 2008 中编译为 Any CPU)是作为 32 位应用程序还是 64 位应用程序运行?
How do I tell if my application (compiled in Visual Studio 2008 as Any CPU) is running as a 32-bit or 64-bit application?
答
if (IntPtr.Size == 8)
{
// 64 bit machine
}
else if (IntPtr.Size == 4)
{
// 32 bit machine
}