C# Directive to indicate 32-bit or 64-bit build

后端 未结 9 1492
你的背包
你的背包 2020-12-16 04:04

Is there some sort of C# directive to use when using a development machine (32-bit or 64-bit) that says something to the effect of:

if (32-bit Vista)
    // set a         


        
9条回答
  •  旧巷少年郎
    2020-12-16 05:03

    I am not sure if this is what you are looking for but I check the IntPtr.Size to detect 32bit versus 64bit runtime. Note that this tells you the runtime environment, you might be running in WOW64

    if (IntPtr.Size == 4)
    {
        //32 bit
    }
    else if (IntPtr.Size == 8)
    {
        //64 bit
    }
    else
    {
        //the future
    }
    

提交回复
热议问题