区分 Windows 版本的最简单方法是什么? [英] What is the simplest way to differentiate between Windows versions?

查看:51
本文介绍了区分 Windows 版本的最简单方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何以编程方式知道我的操作系统是 Longhorn 服务器还是 Vista(客户端).

How do I know programmatically whether my OS is Longhorn server or Vista (client).

似乎两者的主要版本和次要版本相同:
http://msdn.microsoft.com/en-us/library/ms724833.aspx

It seems the major version and minor version are same for both:
http://msdn.microsoft.com/en-us/library/ms724833.aspx

那么,还有更好的选择吗?

So, is there any better alternative?

推荐答案

你链接的同一个页面不是给你答案的吗?

Doesn't that same page you link give you the answer?

Windows Server 2008  OSVERSIONINFOEX.wProductType != VER_NT_WORKSTATION
Windows Vista        OSVERSIONINFOEX.wProductType == VER_NT_WORKSTATION 

只需根据 VER_NT_WORKSTATION

编辑

看起来没有 P/Invoke 就没有办法得到这个.System.Environment.OSVersion 没有公开这个级别的细节,尽管 Microsoft.Win32 命名空间中有一个 internal static class Win32Nativemscorlib 中,据我从反汇编来看,没有任何东西可以使用,更不用说暴露了,wProductType.

Doesn't look like there's a way to get this without P/Invoke. System.Environment.OSVersion doesn't expose this level of detail, and though there is an internal static class Win32Native in the Microsoft.Win32 namespace in mscorlib, as far as I can tell from disassembly, there's nothing that uses, let alone exposes, wProductType.

我已经找到(但没有尝试过)pinvoke.net 上的这个页面.

I have found (but not tried) this page on pinvoke.net.

这篇关于区分 Windows 版本的最简单方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆