How to programmatically tell the difference between XP 64 bit and Server 2003 64 Bit

后端 未结 2 1626
醉话见心
醉话见心 2020-12-11 22:59

I have a program where I need to display a different link to a different download based on what version of windows a user is running.

Using this answer I am able to

相关标签:
2条回答
  • 2020-12-11 23:07

    Assuming you're programming in .Net:

    • http://msdn.microsoft.com/en-us/library/b3022k9x.aspx

    System.Environment properties include:

    • Is64BitOperatingSystem

    • Is64BitProcess

    • OSVersion

    • ProcessorCount

    • Etc etc

    0 讨论(0)
  • 2020-12-11 23:21

    GetVersionEx will set wProductType to VER_NT_SERVER for Windows Server 2003/2008/2008R2/2012, versus VER_NT_WORKSTATION for Windows XP/7/8.

    You already know how to get whether the OS is 32-bit or 64-bit, so with a bit of P/Invoke (GetVersionEx is here), you should be able to figure out the rest.

    Alternatively, if you don't want to use P/Invoke, you could use WMI, and take a look at the Win32_OperatingSystem class, which has the same information in the ProductType property. I wouldn't bother doing it this way unless you really had to.

    0 讨论(0)
提交回复
热议问题