如何以编程方式告诉XP 64位和Server 2003 64位的区别区别、方式、XP、Server

2023-09-04 00:21:02 作者:浪骨

我有一个程序,我需要显示不同的链接到一个不同的下载基于用户正在运行的Windows版本。

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.

使用这个答案我能够检测哪个版本的操作系统是。同时使用这个答案我可以检测,如果我在32位或64位版本的操作系统上运行。

Using this answer I am able to detect which version the OS is. Also using this answer I can detect if I am running on a 32 bit or 64 bit version of the OS.

这会适合我的需要完美,但我碰到的这个页面其中指出,无论 Windows XP的64位版本的Windows Server 2003 使用版本号 5.2

This would suit my needs perfectly, however I came across this page which states that both Windows XP 64-Bit Edition and Windows Server 2003 use the version number 5.2.

如何检测这两个操作系统的区别呢?

How do I detect the difference between those two OS's?

作为一个方面说明,我确实需要把它们发送到不同的位置,如果他们是在2003年的64位或XP 64位,这里有我需要的链接派人到:

As a side note, I do need to send them to a different location if they are on 2003 64 bit or on XP 64 bit, here are the links I am needing to send people to:

远程桌面连接(终端服务客户端6.1)的Windows XP 远程桌面连接(终端服务客户端6.0)的Windows XP x64版 远程桌面连接(终端服务客户端6.0)的Windows服务器2003 远程桌面连接(终端服务客户端6.0)的Windows服务器2003 x64版本 Remote Desktop Connection (Terminal Services Client 6.1) for Windows XP Remote Desktop Connection (Terminal Services Client 6.0) for Windows XP x64 Edition Remote Desktop Connection (Terminal Services Client 6.0) for Windows Server 2003 Remote Desktop Connection (Terminal Services Client 6.0) for Windows Server 2003 x64 Edition

推荐答案

GetVersionEx 将设置 wProductType VER_NT_SERVER 的Windows Server 2003/2008 / 2008R2 / 2012,与 VER_NT_WORKSTATION 适用于Windows XP / 7/8。

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

您已经知道如何让操作系统是32位或64位,所以有位P / Invoke的的(GetVersionEx是的此处),你应该能够找出休息。

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.

另外,如果你不想使用的P / Invoke,你的可以的使用WMI,并采取一看的Win32_OperatingSystem 类,其中有在 ProductType 属性相同的信息。我不会理会做这种方式,除非你真的的有的到。

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.

 
精彩推荐
图片推荐