Jump to content
YOUR-AD-HERE
HOSTING
TOOLS

Locked GetOS en C++


Expermicid

Recommended Posts

Hola a todos. En otro post deje un code para obtener el nombre de usuario y de computadora, en esta ocasion el code es para determinar el sistema operativo en el que se ejecuta.

 

[lenguaje=cpp]#pragma comment(lib, "User32.lib")

#include

#include

 

using namespace std;

 

void main(void) {

 

OSVERSIONINFOEX OSver;

BOOL bOsVersionInfoEx;

 

ZeroMemory(&OSver, sizeof(OSVERSIONINFOEX));

 

OSver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);

bOsVersionInfoEx = GetVersionEx((OSVERSIONINFO*) &OSver);

 

if(bOsVersionInfoEx == 0 )

cout << "Error" << endl;

 

switch(OSver.dwPlatformId) {

case VER_PLATFORM_WIN32s:

cout << "Windows " << OSver.dwMajorVersion << OSver.dwMinorVersion << endl;

break;

case VER_PLATFORM_WIN32_WINDOWS:

if(OSver.dwMinorVersion==0)

cout << "Windows 95" << endl;

else

if(OSver.dwMinorVersion==10)

cout << "Windows 98" << endl;

else

if(OSver.dwMinorVersion==90)

cout << "Windows Me" << endl;

break;

case VER_PLATFORM_WIN32_NT:

if(OSver.dwMajorVersion==5 && OSver.dwMinorVersion==0)

cout << "Windows 2000" << OSver.szCSDVersion << endl;

else

if(OSver.dwMajorVersion==5 && OSver.dwMinorVersion==1)

cout << "Windows XP " << OSver.szCSDVersion << endl;

else

if(OSver.dwMajorVersion==5 && OSver.dwMinorVersion==2)

if (OSver.wProductType==VER_NT_WORKSTATION)

cout << "Windows XP Profesional x64" << endl;

else

cout << "Windows Server 2003" << endl;

else

if(OSver.dwMajorVersion==6 && OSver.dwMinorVersion==0)

if (OSver.wProductType==VER_NT_WORKSTATION)

cout << "Windows Vista" << endl;

else

cout << "Windows Server 2008" << endl;

else

if(OSver.dwMajorVersion==6 && OSver.dwMinorVersion==1)

if (OSver.wProductType==VER_NT_WORKSTATION)

cout << "Windows 7" << endl;

else

cout << "Windows Server 2008 R2" << endl;

else

if(OSver.dwMajorVersion==6 && OSver.dwMinorVersion==2)

if (OSver.wProductType==VER_NT_WORKSTATION)

cout << "Windows 8" << endl;

else

cout << "Windows Server 2012" << endl;

else

if(OSver.dwMajorVersion<=4)

cout << "Windows NT" << endl;

else

cout << "Windows " << OSver.dwMajorVersion << OSver.dwMinorVersion << endl;

break;

}

getchar();

}

[/lenguaje]

 

Gracias a la api GetVersionEx y con la estructura OSVERSIONINFOEX podemos obtener mucha informacion del sistema operativo.

 

Un ejemplo:

 

This is the hidden content, please

 

Si alguien tiene virtuales de varios SO y lo prueba me serviria de mucho para saber que anda bien, ya que yo tengo pocas y estoy teniendo problemas para instalar otros SO. Pero en las que las probe funciono xD

 

Saludos

Edited by Expermicid
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.