3

I would like to know if my current os version is of type Windows Vista (could be 32bit or 64bit). IS there a way to programmatically determine that? I just need to know if its Vista. Thanks!

user1202434
  • 2,243
  • 4
  • 36
  • 53
  • 1
    Might help: http://stackoverflow.com/questions/3483590/in-c-how-can-i-know-programmatically-if-the-operating-system-is-x64-or-x86 – Bridge Sep 04 '12 at 16:19
  • 1
    @Bridge That's actually whether it's 64bit - though this is easier for that: http://msdn.microsoft.com/en-us/library/system.environment.is64bitoperatingsystem.aspx – Reed Copsey Sep 04 '12 at 16:21
  • @ReedCopsey I saw your answer first, but as I re-read the question I interpretted it as he wanted to know if it was 32bit/64bit version as well. I didn't label the link as a "potential duplicate" question for exactly that reason :-) (and that link you've posted here is already mentioned in the question I linked) – Bridge Sep 04 '12 at 22:55
  • @Bridge I mentioned because the accepted answer there is actually not correct - it shows whehter it's *running* x86, not whether the OS is 32bit... – Reed Copsey Sep 04 '12 at 23:02
  • @ReedCopsey The second answer there is correct - lets hope OP is using .NET 4 then. – Bridge Sep 04 '12 at 23:06

1 Answers1

8

You can check Environment.OSVersion to get the OperatingSystem information.

var version = Environment.OSVersion.Version;
bool isVista =  version.Major == 6 && version.Minor == 0;
Reed Copsey
  • 554,122
  • 78
  • 1,158
  • 1,373
  • 2
    This question has an answer with a grid that might be useful for detecting other versions: http://stackoverflow.com/questions/2819934/detect-windows-7-in-net – Cypher Sep 04 '12 at 16:32
  • This can also return true for Windows Server 2008. Mentioning it in the question might help. See http://msdn.microsoft.com/en-us/library/windows/desktop/ms724832(v=vs.85).aspx – nawfal Aug 07 '13 at 17:50