开发者

How to detect OS of Win7 Home Premium, Win7 Professional, Win7 Enterprise or Win7 ultimate?

How to d开发者_如何学Goetect OS of Win7 Home Premium, Win7 Professional, Win7 Enterprise or Win7 ultimate?


Determine Windows Version and Edition

Check this post Detect OS version and see if it helps. This is for XP but it should help you little bit.

Check this one too http://andrewensley.com/2009/06/c-detect-windows-os-part-1/ and this one is for Vista.


I'm using the key "Edition" under HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion to determine windows version, I don't know if it's unique? Thanks.

EditionID = ultimate EditionID = Enterprise EditionID = Professional EditionID = Premium


He tagged the question with win32 api.

GetVersionEx() et al. is what you need. See this code sample for a more in depth example.


In Delphi I would use this method for Windows XP and above, it seems to be the most straight forward and this registry key should always exist

var 
  Reg : TRegistry
begin
  Reg := TRegistry.Create();
  Reg.RootKey := HKEY_LOCAL_MACHINE;
  Reg.OpenKey('Software\Microsoft\Windows NT\CurrentVersion', false);
  Caption := Reg.ReadString('ProductName');
  Reg.Free;
end

You will need to include Registry as a unit in your app


Try WMI: host localhost, namespace root\cimv2 (these are the defaults) SELECT Caption FROM Win32_OperatingSystem


Using approach like checking the version number is incorrect in my opinion. I was reading an article about best practices (lost the link) and it clearly said never use these version numbers which microsoft may change in future updates to detect windows version.

Windows Vista is version 6.0 and Windows 7 is 6.1 which ideally should have been 7. This is not a reliable at all.

A better way is to check the existance of features which are particular to each version of windows. For ex, in windows vista/7 home basic you would not find aero experience. Same way ultimate edition comes with bitlocker etc and home premium doesnt.

MSDN will detail what features are available in each version and how to query if its available. Based on this you can decide what is the base version of windows. Also you can use to query version info from the system dlls to detect exact windows build date etc.

With windows 7 new DLLs have been added in the system32 as compared to vista. So when you search for particular dlls you would know if its windows 7 system or old versions like xp/vista.


You can use GetVersionEx to determine the core OS version, but this method gets messy faced with multiple products which use a common core, and I don't think you can programatically decode this information down to the level of a particular SKU. The best you could get away with is finding a string and letting the user see that. Some simple OSVERSIONINFOEX mappings are shown in the remarks section of the docs here

Read this Microsoft blog posting for current thinking on this topic. Basically it comes down to using GetProcAddress to look for the API you're trying to use and degrading gracefully.


I came here looking for the same thing but for powershell and found this as the easiest:

(gwmi -class Win32_OperatingSystem).name

Which returns a line like:

Microsoft Windows 7 Enterprise |C:\Windows|\Device\Harddisk0\Partition2

if you want version numbers etc., use a verbose form like

gwmi -class Win32_OperatingSystem | FL *

and pick out what you need

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜