mercredi 7 mai 2014

c ++ - version Windows de vérifier - Stack Overflow


How I can check in C++ if Windows version installed on computer is Windows Vista and higher (Windows 7)?




Similar to other tests for checking the version of Windows NT:


OSVERSIONINFO	vi;

memset (&vi, 0, sizeof vi);
vi .dwOSVersionInfoSize = sizeof vi;
GetVersionEx (&vi);
if (vi.dwPlatformId == VER_PLATFORM_WIN32_NT && vi.dwMajorVersion >= 6)



Use GetVersionEx API function defined in kernel32.dll:


bool IsWindowsVistaOrHigher() {
OSVERSIONINFO osvi;
ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&osvi);
return osvi.dwMajorVersion >= 6;
}



I think you're looking for the GetVersionEx function.




This Microsoft support page gives you details for older versions.


You could implement the code and run it on a Vista and Windows-7 machine to check the values returned.




You could use the GetVersion() or GetVersionEx() function in the kernel32.dll. This two functions are only available on Windows 2000 or later.


To read more about this look at http://msdn.microsoft.com/en-us/library/ms724451%28VS.85%29.aspx.




In Visual Studio 2013 or higher, you can also use the new Version Helper functions.


There are methods for many different Windows versions. Example:


#include <VersionHelpers.h>

if (!IsWindowsVistaOrGreater())
{
MessageBox(NULL, "You need at least Windows Vista", "Version Not Supported", MB_OK);
}

More information here



How I can check in C++ if Windows version installed on computer is Windows Vista and higher (Windows 7)?



Similar to other tests for checking the version of Windows NT:


OSVERSIONINFO	vi;

memset (&vi, 0, sizeof vi);
vi .dwOSVersionInfoSize = sizeof vi;
GetVersionEx (&vi);
if (vi.dwPlatformId == VER_PLATFORM_WIN32_NT && vi.dwMajorVersion >= 6)


Use GetVersionEx API function defined in kernel32.dll:


bool IsWindowsVistaOrHigher() {
OSVERSIONINFO osvi;
ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&osvi);
return osvi.dwMajorVersion >= 6;
}


I think you're looking for the GetVersionEx function.



This Microsoft support page gives you details for older versions.


You could implement the code and run it on a Vista and Windows-7 machine to check the values returned.



You could use the GetVersion() or GetVersionEx() function in the kernel32.dll. This two functions are only available on Windows 2000 or later.


To read more about this look at http://msdn.microsoft.com/en-us/library/ms724451%28VS.85%29.aspx.



In Visual Studio 2013 or higher, you can also use the new Version Helper functions.


There are methods for many different Windows versions. Example:


#include <VersionHelpers.h>

if (!IsWindowsVistaOrGreater())
{
MessageBox(NULL, "You need at least Windows Vista", "Version Not Supported", MB_OK);
}

More information here


Related Posts:

0 commentaires:

Enregistrer un commentaire