Cstring sosinfo, stmp; osversioninfoex osvi; bool bosversioninfoex; // try calling getversionex using the osversioninfoex structure. // if that fails, try using the osversioninfo structure. zeromemory (& osvi, sizeof (osversioninfoex); osvi. dwosversioninfosize = sizeof (osversioninfoex); If (! (Bosversioninfoex = getversionex (osversioninfo *) & osvi) {osvi. dwosversioninfosize = sizeof (osversioninfo); If (! Getversionex (osversioninfo *) & osvi) return false;} switch (osvi. dwplatformid) {// test for the Windows NT product family. case ver_platform_win32_nt: If (osvi. dwmajorversion> 5) sosinfo = "Microsoft Windows Vista,"; // test for the specific product family. if (osvi. dwmajorversion = 5 & osvi. dwminorversion = 2) sosinfo = "Microsoft Windows Server 2003 Family,"; if (osvi. dwmajorversion = 5 & & Osvi. dwminorversion = 1) sosinfo = "Microsoft Windows XP"; if (osvi. dwmajorversion = 5 & osvi. dwminorversion = 0) sosinfo = "Microsoft Windows 2000"; if (osvi. dwmajorversion <= 4) sosinfo = "Microsoft Windows NT"; // test for specific product on Windows NT 4.0 SP6 and later. if (bosversioninfoex) {// test for the workstation type. if (osvi. wproducttype = ver_nt_workstation) {If (osvi. dwmaj Orversion = 4) sosinfo + = "Workstation 4.0"; else if (osvi. wsuitemask & ver_suite_personal) sosinfo + = "Home Edition"; elsesosinfo + = "professional" ;}// test for the server type. else if (osvi. wproducttype = ver_nt_server) {If (osvi. dwmajorversion = 5 & osvi. dwminorversion = 2) {If (osvi. wsuitemask & ver_suite_datacenter) sosinfo + = "datacenter edition"; else if (osvi. wsuitemask & ver_suite _ Enterprise) sosinfo + = "Enterprise Edition"; else if (osvi. wsuitemask = ver_suite_blade) sosinfo + = "web edition"; elsesosinfo + = "Standard Edition";} else if (osvi. dwmajorversion = 5 & osvi. dwminorversion = 0) {If (osvi. wsuitemask & ver_suite_datacenter) sosinfo + = "datacenter server"; else if (osvi. wsuitemask & ver_suite_enterprise) sosinfo + = "Advanced Server"; elsesosinfo + = "server";} el Se // Windows NT 4.0 {If (osvi. wsuitemask & ver_suite_enterprise) sosinfo + = "Server 4.0, Enterprise Edition"; elsesosinfo ++ = "Server 4.0 ";}}} else // test for specific product on Windows NT 4.0 SP5 and earlier {hkey; char szproducttype [bufsize]; DWORD dwbuflen = bufsize; long LRET; LRET = regopenkeyex (HKEY_LOCAL_MACHINE, "system // CurrentControlSet // control // productoptions", 0, key_query_value, & hkey ); If (LRET! = Error_success) return false; LRET = regqueryvalueex (hkey, "producttype", null, null, (lpbyte) szproducttype, & dwbuflen); If (LRET! = Error_success) | (dwbuflen> bufsize) return false; regclosekey (hkey); If (lstrcmpi ("winnt", szproducttype) = 0) printf ("workstation "); if (lstrcmpi ("lanmannt", szproducttype) = 0) printf ("server"); If (lstrcmpi ("servernt", szproducttype) = 0) sosinfo + = "Advanced Server"; stmp. format ("% d. % d ", osvi. dwmajorversion, osvi. dwminorversion); sosinfo + = stmp;} // display Service Pack (if any) and build number. if (osvi. dwmajorversion = 4 & lstrcmpi (osvi. szcsdversion, "Service Pack 6") = 0) {hkey; long LRET; // test for SP6 versus SP6a. LRET = regopenkeyex (HKEY_LOCAL_MACHINE, "software // Microsoft // Windows NT // CurrentVersion // hotfix // q246009", 0, key_query_value, & hkey ); if (LRET = error_success) {stmp. format ("Service Pack 6a (build % d)/n", osvi. dwbuildnumber & 0 xFFFF); sosinfo + = stmp;} else // Windows NT 4.0 prior to SP6a {stmp. format ("% s (build % d)/n", osvi. szcsdversion, osvi. dwbuildnumber & 0 xFFFF); sosinfo + = stmp;} regclosekey (hkey);} else // Windows NT 3.51 and earlier or Windows 2000 and later {stmp. format ("% s (build % d)/n", osvi. szcsdversion, osvi. dwbuildnumber & 0 xFFFF); sosinfo + = stmp;} break; // test for the Windows 95 product family. case ver_platform_win32_windows: If (osvi. dwmajorversion = 4 & osvi. dwminorversion = 0) {sosinfo = "Microsoft Windows 95"; if (osvi. szcsdversion [1] ==& apos; C & apos; | osvi. szcsdversion [1] ==& apos; B & apos;) sosinfo + = "osr2" ;}if (osvi. dwmajorversion = 4 & osvi. dwminorversion = 10) {sosinfo = "Microsoft Windows 98"; if (osvi. szcsdversion [1] ==& apos; A & apos;) sosinfo + = "se" ;}if (osvi. dwmajorversion = 4 & osvi. dwminorversion = 90) {sosinfo = "Microsoft Windows Millennium Edition/N";} break; Case ver_platform_win32s: sosinfo + = "Microsoft win32s/N"; break;} return sosinfo;
Obtain the version information of the Windows operating system: (copy from msdn and add a sentence)
My system version information: Microsoft Windows Vista, Home Edition (build 6000)