Hi,
I think the foll. code snippet will be useful for u.
#include <windows.h>
#include <stdio.h>
BOOL DisplaySystemVersion()
{
OSVERSIONINFOEX osvi;
BOOL bOsVersionInfoEx;
// Try calling GetVersionEx using the OSVERSIONINFOEX structure,
// which is supported on Windows 2000.
//
// If that fails, try using the OSVERSIONINFO structure.
ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
if( !(bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO *) &osvi)) )
{
// If OSVERSIONINFOEX doesn’t work, try OSVERSIONINFO.
osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) )
return FALSE;
}
switch (osvi.dwPlatformId)
{
case VER_PLATFORM_WIN32_NT:
// Test for the product.
if ( osvi.dwMajorVersion <= 4 )
printf( "Microsoft Windows NT ");
if ( osvi.dwMajorVersion == 5 )
printf ("Microsoft Windows 2000 ");
// Test for workstation versus server.
if( bOsVersionInfoEx )
{
if ( osvi.wProductType == VER_NT_WORKSTATION )
printf ( "Professional " );
if ( osvi.wProductType == VER_NT_SERVER )
printf ( "Server " );
}
else
{
HKEY hKey;
char szProductType[80];
DWORD dwBufLen;
RegOpenKeyEx( HKEY_LOCAL_MACHINE,
“SYSTEM\CurrentControlSet\Control\ProductOptions”,
0, KEY_QUERY_VALUE, &hKey );
RegQueryValueEx( hKey, “ProductType”, NULL, NULL,
(LPBYTE) szProductType, &dwBufLen);
RegCloseKey( hKey );
if ( lstrcmpi( “WINNT”, szProductType) == 0 )
printf( "Workstation " );
if ( lstrcmpi( “SERVERNT”, szProductType) == 0 )
printf( "Server " );
}
// Display version, service pack (if any), and build number.
printf (“version %d.%d %s (Build %d)\n”,
osvi.dwMajorVersion,
osvi.dwMinorVersion,
osvi.szCSDVersion,
osvi.dwBuildNumber & 0xFFFF);
break;
case VER_PLATFORM_WIN32_WINDOWS:
if ((osvi.dwMajorVersion > 4) ||
((osvi.dwMajorVersion == 4) && (osvi.dwMinorVersion > 0)))
{
printf ("Microsoft Windows 98 ");
}
else printf ("Microsoft Windows 95 ");
break;
case VER_PLATFORM_WIN32s:
printf ("Microsoft Win32s ");
break;
}
return TRUE;
}
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Zygmunt Wiercioch
Sent: Friday, May 11, 2001 12:12 PM
To: NT Developers Interest List
Subject: [ntdev] RE: Any api to find the System is Server or workstati
on ?
Max,
I did not make my post as clear as I may have. From the relevant API
documentation:
Before calling the GetVersionEx function, set the dwOSVersionInfoSize member
of the OSVERSIONINFO data structure to sizeof(OSVERSIONINFO).
Windows NT 4.0 SP6 and later: This member can be a pointer to an
OSVERSIONINFOEX structure. Set the dwOSVersionInfoSize member to
sizeof(OSVERSIONINFOEX) to identify the structure type.
It’s the support of OSVERSIONEX structure (which contains the extra bits
that indicate server/pro/personal etc) that reauires SP6.
Zyg
-----Original Message-----
From: Maxim S. Shatskih [mailto:xxxxx@storagecraft.com]
Sent: May 11, 2001 13:11
To: NT Developers Interest List
Subject: [ntdev] RE: Any api to find the System is Server or workstation
?
> See GetVersionEx and the OSVERSIONEX structure. Unfortunately, for NT
4.0,
> the call is only supported with Service Pack 6.
Wrong. From the MSDN library:
“Windows NT/2000: Requires Windows NT 3.5 or later.”
You could mixed GetVersionEx with VerifyVersionInfo.
Max
—
You are currently subscribed to ntdev as: xxxxx@jetform.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
—
You are currently subscribed to ntdev as: xxxxx@cmoschips.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
—
You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com</stdio.h></windows.h>