tags:

views:

97

answers:

2

how do I know programaticcally whether my OS is Longhorn server or vista (client).

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

so, is there any better alternative?

+1  A: 

For Server,

OSVERSIONINFOEX.wProductType != VER_NT_WORKSTATION

For Workstation

OSVERSIONINFOEX.wProductType == VER_NT_WORKSTATION
LnDCobra
+3  A: 

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 

Just check the wProductType member against VER_NT_WORKSTATION

edit

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.

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

AakashM
seems it needs a pinvoke. is there a solution avoiding this pinvoke?
satya
Thanks AakashM. Even I couldnt find one without P/Invoke. anyways, thanks for ur help
satya