Find Windows System Version(from Windows XP SP2 and above) using C++



#include "windows.h"
#include "tchar.h"
#include "stdio.h"
#include "strsafe.h"

#pragma comment(lib, "User32.lib")

#define BUFSIZE 256

typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO);
typedef BOOL (WINAPI *PGPI)(DWORD, DWORD, DWORD, DWORD, PDWORD);

BOOL GetOSDisplayString( LPTSTR pszOS)
{
OSVERSIONINFOEX osvi;
SYSTEM_INFO si;
PGNSI pGNSI;
PGPI pGPI;
BOOL bOsVersionInfoEx;
DWORD dwType;

ZeroMemory(&si, sizeof(SYSTEM_INFO));
ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));

osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
bOsVersionInfoEx = GetVersionEx((OSVERSIONINFO*) &osvi);

if(bOsVersionInfoEx != NULL ) return 1;

// Call GetNativeSystemInfo if supported or GetSystemInfo otherwise.

pGNSI = (PGNSI) GetProcAddress(
GetModuleHandle(TEXT("kernel32.dll")),
"GetNativeSystemInfo");
if(NULL != pGNSI)
pGNSI(&si);
else GetSystemInfo(&si);

if ( VER_PLATFORM_WIN32_NT==osvi.dwPlatformId &&
osvi.dwMajorVersion > 4 )
{
StringCchCopy(pszOS, BUFSIZE, TEXT("Microsoft "));

// Test for the specific product.

if ( osvi.dwMajorVersion == 6 )
{
if( osvi.dwMinorVersion == 0 )
{
if( osvi.wProductType == VER_NT_WORKSTATION )
StringCchCat(pszOS, BUFSIZE, TEXT("Windows Vista "));
else StringCchCat(pszOS, BUFSIZE, TEXT("Windows Server 2008 " ));
}

if ( osvi.dwMinorVersion == 1 )
{
if( osvi.wProductType == VER_NT_WORKSTATION )
StringCchCat(pszOS, BUFSIZE, TEXT("Windows 7 "));
else StringCchCat(pszOS, BUFSIZE, TEXT("Windows Server 2008 R2 " ));
}

pGPI = (PGPI) GetProcAddress(
GetModuleHandle(TEXT("kernel32.dll")),
"GetProductInfo");

pGPI( osvi.dwMajorVersion, osvi.dwMinorVersion, 0, 0, &dwType);

switch( dwType )
{
case PRODUCT_ULTIMATE:
StringCchCat(pszOS, BUFSIZE, TEXT("Ultimate Edition" ));
break;
case PRODUCT_PROFESSIONAL:
StringCchCat(pszOS, BUFSIZE, TEXT("Professional" ));
break;
case PRODUCT_HOME_PREMIUM:
StringCchCat(pszOS, BUFSIZE, TEXT("Home Premium Edition" ));
break;
case PRODUCT_HOME_BASIC:
StringCchCat(pszOS, BUFSIZE, TEXT("Home Basic Edition" ));
break;
case PRODUCT_ENTERPRISE:
StringCchCat(pszOS, BUFSIZE, TEXT("Enterprise Edition" ));
break;
case PRODUCT_BUSINESS:
StringCchCat(pszOS, BUFSIZE, TEXT("Business Edition" ));
break;
case PRODUCT_STARTER:
StringCchCat(pszOS, BUFSIZE, TEXT("Starter Edition" ));
break;
case PRODUCT_CLUSTER_SERVER:
StringCchCat(pszOS, BUFSIZE, TEXT("Cluster Server Edition" ));
break;
case PRODUCT_DATACENTER_SERVER:
StringCchCat(pszOS, BUFSIZE, TEXT("Datacenter Edition" ));
break;
case PRODUCT_DATACENTER_SERVER_CORE:
StringCchCat(pszOS, BUFSIZE, TEXT("Datacenter Edition (core installation)" ));
break;
case PRODUCT_ENTERPRISE_SERVER:
StringCchCat(pszOS, BUFSIZE, TEXT("Enterprise Edition" ));
break;
case PRODUCT_ENTERPRISE_SERVER_CORE:
StringCchCat(pszOS, BUFSIZE, TEXT("Enterprise Edition (core installation)" ));
break;
case PRODUCT_ENTERPRISE_SERVER_IA64:
StringCchCat(pszOS, BUFSIZE, TEXT("Enterprise Edition for Itanium-based Systems" ));
break;
case PRODUCT_SMALLBUSINESS_SERVER:
StringCchCat(pszOS, BUFSIZE, TEXT("Small Business Server" ));
break;
case PRODUCT_SMALLBUSINESS_SERVER_PREMIUM:
StringCchCat(pszOS, BUFSIZE, TEXT("Small Business Server Premium Edition" ));
break;
case PRODUCT_STANDARD_SERVER:
StringCchCat(pszOS, BUFSIZE, TEXT("Standard Edition" ));
break;
case PRODUCT_STANDARD_SERVER_CORE:
StringCchCat(pszOS, BUFSIZE, TEXT("Standard Edition (core installation)" ));
break;
case PRODUCT_WEB_SERVER:
StringCchCat(pszOS, BUFSIZE, TEXT("Web Server Edition" ));
break;
}
}

if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2 )
{
if( GetSystemMetrics(SM_SERVERR2) )
StringCchCat(pszOS, BUFSIZE, TEXT( "Windows Server 2003 R2, "));
else if ( osvi.wSuiteMask & VER_SUITE_STORAGE_SERVER )
StringCchCat(pszOS, BUFSIZE, TEXT( "Windows Storage Server 2003"));
else if ( osvi.wSuiteMask & VER_SUITE_WH_SERVER )
StringCchCat(pszOS, BUFSIZE, TEXT( "Windows Home Server"));
else if( osvi.wProductType == VER_NT_WORKSTATION &&
si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64)
{
StringCchCat(pszOS, BUFSIZE, TEXT( "Windows XP Professional x64 Edition"));
}
else StringCchCat(pszOS, BUFSIZE, TEXT("Windows Server 2003, "));

// Test for the server type.
if ( osvi.wProductType != VER_NT_WORKSTATION )
{
if ( si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_IA64 )
{
if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
StringCchCat(pszOS, BUFSIZE, TEXT( "Datacenter Edition for Itanium-based Systems" ));
else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
StringCchCat(pszOS, BUFSIZE, TEXT( "Enterprise Edition for Itanium-based Systems" ));
}

else if ( si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64 )
{
if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
StringCchCat(pszOS, BUFSIZE, TEXT( "Datacenter x64 Edition" ));
else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
StringCchCat(pszOS, BUFSIZE, TEXT( "Enterprise x64 Edition" ));
else StringCchCat(pszOS, BUFSIZE, TEXT( "Standard x64 Edition" ));
}

else
{
if ( osvi.wSuiteMask & VER_SUITE_COMPUTE_SERVER )
StringCchCat(pszOS, BUFSIZE, TEXT( "Compute Cluster Edition" ));
else if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
StringCchCat(pszOS, BUFSIZE, TEXT( "Datacenter Edition" ));
else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
StringCchCat(pszOS, BUFSIZE, TEXT( "Enterprise Edition" ));
else if ( osvi.wSuiteMask & VER_SUITE_BLADE )
StringCchCat(pszOS, BUFSIZE, TEXT( "Web Edition" ));
else StringCchCat(pszOS, BUFSIZE, TEXT( "Standard Edition" ));
}
}
}

if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 )
{
StringCchCat(pszOS, BUFSIZE, TEXT("Windows XP "));
if( osvi.wSuiteMask & VER_SUITE_PERSONAL )
StringCchCat(pszOS, BUFSIZE, TEXT( "Home Edition" ));
else StringCchCat(pszOS, BUFSIZE, TEXT( "Professional" ));
}

if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0 )
{
StringCchCat(pszOS, BUFSIZE, TEXT("Windows 2000 "));

if ( osvi.wProductType == VER_NT_WORKSTATION )
{
StringCchCat(pszOS, BUFSIZE, TEXT( "Professional" ));
}
else
{
if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
StringCchCat(pszOS, BUFSIZE, TEXT( "Datacenter Server" ));
else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
StringCchCat(pszOS, BUFSIZE, TEXT( "Advanced Server" ));
else StringCchCat(pszOS, BUFSIZE, TEXT( "Server" ));
}
}

// Include service pack (if any) and build number.

if( _tcslen(osvi.szCSDVersion) > 0 )
{
StringCchCat(pszOS, BUFSIZE, TEXT(" ") );
StringCchCat(pszOS, BUFSIZE, osvi.szCSDVersion);
}

TCHAR buf[80];

StringCchPrintf( buf, 80, TEXT(" (build %d)"), osvi.dwBuildNumber);
StringCchCat(pszOS, BUFSIZE, buf);

if ( osvi.dwMajorVersion >= 6 )
{
if ( si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64 )
StringCchCat(pszOS, BUFSIZE, TEXT( ", 64-bit" ));
else if (si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_INTEL )
StringCchCat(pszOS, BUFSIZE, TEXT(", 32-bit"));
}

return TRUE;
}

else
{
printf( "This sample does not support this version of Windows.\n");
return FALSE;
}
}

int __cdecl _tmain()
{
TCHAR szOS[BUFSIZE];

if( GetOSDisplayString( szOS ) )
_tprintf( TEXT("\n%s\n"), szOS );
}

VMware software products - ESXi, vCenter, vMotion

ESX Server

VMware’s ESX server is at the highest end of features and price of all the VMware server applications. The ESX actually loads right on to “bare-metal” servers. Thus, there is no need to first load an underlying operating system prior to loading VMware ESX. What is unique about ESX is that it comes with its own modified Linux Kernel called VMKernel (based on Red Hat Enterprise Linux). ESX is now sold in a suite of products called VMware Infrastructure.


VMWare Server

VMware’s Server is a FREE VMware virtualization product built for use in production servers. Unlike ESX, VMware Server still uses the underlying host operating system. With VMware Server, you loose the some of the functionality and performance of the ESX server but don’t have as great of price tag (its free!)


Workstation

VMware’s Workstation is for use on a client workstation. For example, say that I want to run both Windows 2003 server and Linux Fedora Core 5 on my desktop workstation, which is running Windows XP. VMware Workstation would be the program I would use to do this. This would allow me the flexibility to run these guest operating systems to test various applications and features. I could also create snapshots of them to capture their configuration at a certain point in time and easily duplicate them to create other virtual machines (such as moving them to a VMware Server).



VirtualCenter

Virtual Center provides a centralized management console for all VMware servers. If you plan to grow your farm of virtualized servers into the ten’s and hundreds, over time, you should have Virtual Center in your plans.


Vmotion

Like magic, VMotion can move a running virtual server to another physical server, without interrupting that server’s requests. This can be done for maintenance of hardware or to better balance workload. VMotion requires a SAN be used for these virtual machines. Both Virtual Center and VMotion are part of the VMWare vManage offering.


VMware Converter

The VMware Converter is used to move physical machine operating systems to virtual machines. This tool automates the migration to virtual machines. Besides migrating, the Converter can be used to create images of physical systems for disaster recovery purposes. Currently in Beta, the VMware Converter will replace the P2V Assistant.


ref:

Integrate with Intel AMT(Active Management Technology)

Intel Active Management Technology (AMT) is hardware-based technology for remotely managing and securing PCs out-of-band. Currently, Intel AMT is available in desktop PCs with Intel Core 2 processor with Intel vPro technology and available in laptop PCs with Centrinoor Centrino 2 platform with vPro technology.

Intel® Active Management Technology (Intel® AMT) is a capability embedded in Intel-based platforms that enhances the ability of IT organizations to manage enterprise computing facilities. Intel AMT operates independently of the platform processor and operating system. Remote platform management applications can access Intel AMT securely, even when the platform is turned off, as long as the platform is connected to line power and to a network. Independent software vendors (ISVs) can build applications that take advantage of the features of Intel AMT using the application programming interface (API).

Intel AMT SDK latest version is v7.0

ref:

Wiki - http://en.wikipedia.org/wiki/Intel_Active_Management_Technology

Intel AMT implementation & reference guide - http://software.intel.com/sites/manageability/AMT_Implementation_and_Reference_Guide/default.htm

Intel AMT integration Reference guide - http://download.intel.com/support/motherboards/desktop/sb/amt_quick_start_guide1.pdf

AMT Architecture Guide - http://software.intel.com/en-us/articles/architecture-guide-intel-active-management-technology/

AMT Serial Over Lan(SOL) - http://software.intel.com/en-us/articles/using-intel-amt-serial-over-lan-to-the-fullest/

Intel AMT SCS 7.0 - http://software.intel.com/en-us/blogs/2011/03/18/discover-the-new-intel-amt-scs-70/

Intel® vPro™ Enabling Tools for Now and the Future (Intel® Manageability Checker v2.0) -

http://software.intel.com/en-us/blogs/2011/04/15/intel-vpro-enabling-tools-for-now-and-the-future/

Intel Management forum - http://software.intel.com/en-us/forums/manageability-software-development/

Intel AMT posts/blog by Ajit Illendula - http://software.intel.com/en-us/blogs/author/ajith-illendula/

Web Services Management (WS-Man) Specification - http://dmtf.org/standards/wsman

Open WS-Man Specification - http://openwsman.org/


Integrate with Windows Security Center(WSC)

Windows XP SP2 and above support Windows Security Center (WSC) integration. Windows XP SP2 & Windows Vista use WMI interface to communicate with WSC.

Beginning in Windows Vista Service Pack 1 (SP1), application developers must use a new application programming interface (API) to provide status updates to Windows Security Center for developing firewall, antivirus, and malicious software detection and removal applications that report status to Windows Security Center in Windows Vista. You need to make sure that you sign the binary that communicates with WSC & compile the binary with /integritycheck linker flag.

Windows Vista SP1 & above supports the IWscAVStatus API for antivirus applications to register, unregister, and send status updates.

FAQ:

1. How to enable Security Center AntiVirus view on Windows XP SP2: Change Group Policy

Answer:

a. To enable it Security Center Properties , do the following on your Windows XP SP2 workstation:

START -> RUN -> gpedit.msc

In Group Policy go to Computer Configuration -> Administrative Templates -> WINDOWS COMPONENTS (not System as documented) -> Security Center -> Properties -> Enable.

b. Start ‘Security Center’(wscsvc) Service.

Note:

Wscsvc depends on ‘Windows Management Instrumentation’ (wimmgmt) service. It means when wscsvc is started successfully, we are sure that WMI service is running great.

Wscsvc service is hosted by svchost.exe ; svchost.exe loads wscsvc.dll (present in \windows\system32 folder)

Winmgmt service is hosted by svchost.exe ; svchost.exe loads WMIsvc.dll (present in \windows\system32\wbem folder)