SoloCodigo

Programación General => C/C++ => C++ Builder => Mensaje iniciado por: betitono1 en Martes 1 de Junio de 2004, 08:09

Título: Version De Mi Sistema Operativo
Publicado por: betitono1 en Martes 1 de Junio de 2004, 08:09
Alguien sabe como puedo saberpor medio de un prog que sistema operativo esta instalado en la maq donde esta instalado el programa.

Saludos
Título: Re: Version De Mi Sistema Operativo
Publicado por: The Black Boy en Martes 1 de Junio de 2004, 17:17
El Sgte es el .cpp
Código: Text
  1.  
  2. #include <vcl.h>
  3. #pragma hdrstop
  4.  
  5. #include "EstacionWindows.h"
  6. #include <winioctl.h>
  7. //---------------------------------------------------------------------------
  8. #pragma package(smart_init)
  9.  
  10. AnsiString __fastcall TEstacionWindows::ObtenerVersionSO( )
  11. {
  12.   AnsiString szVersionSO;
  13.   OSVERSIONINFO VersionSO;
  14.  
  15.   VersionSO.dwOSVersionInfoSize = sizeof( OSVERSIONINFO );
  16.   if( GetVersionEx( &VersionSO ) )
  17.   {
  18.     switch( VersionSO.dwPlatformId )
  19.     {
  20.       case VER_PLATFORM_WIN32s:
  21.         szVersionSO = "Win32 on Windows 3.1";
  22.         break;
  23.  
  24.       case VER_PLATFORM_WIN32_WINDOWS:
  25.         szVersionSO = "Windows 95";
  26.         break;
  27.  
  28.       case VER_PLATFORM_WIN32_NT:
  29.         switch( VersionSO.dwMajorVersion )
  30.         {
  31.           case 4:
  32.             szVersionSO = "Windows NT";
  33.             break;
  34.  
  35.           case 5:
  36.             switch( VersionSO.dwMinorVersion )
  37.             {
  38.               case 0:
  39.                 szVersionSO = "Windows 2000";
  40.                 break;
  41.  
  42.               case 1:
  43.                 szVersionSO = "Windows XP";
  44.                 break;
  45.  
  46.               default:
  47.                 szVersionSO = "Win32 Desconocido";
  48.                 break;
  49.             }
  50.             break;
  51.  
  52.           default:
  53.             szVersionSO = "Win32 Desconocido";
  54.             break;
  55.         }
  56.         break;
  57.  
  58.       default:
  59.         szVersionSO = "Sistema Desconocido";
  60.     }
  61.   }
  62.  
  63.   return szVersionSO;
  64. }
  65.  
  66.  

espero te sirva...  

y este es el .h
Código: Text
  1.  
  2. #ifndef EstacionNTH
  3. #define EstacionNTH
  4.  
  5. class TEstacionWindows
  6. {
  7.   private:
  8.     TRegistry *Registry;
  9.   public:
  10.                 AnsiString __fastcall ObtenerVersionSO( );
  11. };#endif
  12.  
  13.  

Saludos :hola:
Título: Re: Version De Mi Sistema Operativo
Publicado por: The Black Boy en Martes 1 de Junio de 2004, 17:26
el anterior codigo :good:  estaria en el computador al que se le quiere averiguar la version del SO y creo que eso es lo que pides

si es asi ???

Saludos   :hola:
Título: Re: Version De Mi Sistema Operativo
Publicado por: betitono1 en Miércoles 2 de Junio de 2004, 15:57
Muchas gracias amigo The Black Boy me ha funcionado a la perfeccion, espero seguir contando con tu ayuda, una ultima pregunta en esta discusion como puedo saber cuanta memoria tiene la maq, y el hardware quq tiene instalado ( CD_ROM, DVD, floppy 3 1/2, y la informacion el procesador) se que es mucho lo que pido pero si hay alguna respuesta de las opciones q te solicito te lo agradeceria.


Gracias.

Saludos.
Título: Re: Version De Mi Sistema Operativo
Publicado por: betitono1 en Miércoles 2 de Junio de 2004, 16:03
Disculpa falta la compraración para el Windows 98, eso en q parte lo veo , lo pruebo en este sistema para ver cual me selecciona?.


Saludos.
Título: Re: Version De Mi Sistema Operativo
Publicado por: The Black Boy en Miércoles 2 de Junio de 2004, 17:06
Código: Text
  1.  
  2. AnsiString __fastcall TEstacionWindows::ObtenerVersionExSO( )
  3. {
  4.   AnsiString szVersionSO;
  5.   OSVERSIONINFO VersionSO;
  6.  
  7.   VersionSO.dwOSVersionInfoSize = sizeof( OSVERSIONINFO );
  8.   if( GetVersionEx( &VersionSO ) )
  9.   {
  10.     switch( VersionSO.dwPlatformId )
  11.     {
  12.       case VER_PLATFORM_WIN32s:
  13.         szVersionSO = "Win32 on Windows 3.1 Versión ";
  14.         break;
  15.  
  16.       case VER_PLATFORM_WIN32_WINDOWS:
  17.         szVersionSO = "Windows 95 Versión ";
  18.         break;
  19.  
  20.       case VER_PLATFORM_WIN32_NT:
  21.         if( VersionSO.dwMajorVersion >= 5 )
  22.         {
  23.           szVersionSO = "Windows 2000 Versión ";
  24.         }
  25.         else
  26.         {
  27.           szVersionSO = "Windows NT Versión ";
  28.         }
  29.         break;
  30.  
  31.       default:
  32.         szVersionSO = "Sistema Desconocido ";
  33.     }
  34.     szVersionSO += VersionSO.dwMajorVersion;
  35.     szVersionSO += ".";
  36.     szVersionSO += VersionSO.dwMinorVersion;
  37.     szVersionSO += " ";
  38.     szVersionSO += VersionSO.szCSDVersion;
  39.     szVersionSO += " Build ";
  40.     szVersionSO += VersionSO.dwBuildNumber;
  41.   }
  42.  
  43.   return szVersionSO;
  44. }
  45.  
  46. AnsiString __fastcall TEstacionWindows::ObtenerTipoProcesador( )
  47. {
  48.   AnsiString szTipoProcesador;
  49.   HANDLE hCPUID;
  50.   VOID ( WINAPI *pGetProcessorType )( LPSTR, LPSTR );
  51.   char szProcessorType[ 255 ], szCoprocessorType[ 255 ];
  52.  
  53.   szTipoProcesador = "";
  54.   memset( szProcessorType, 0, 255 );
  55.   memset( szCoprocessorType, 0, 255 );
  56.   hCPUID = LoadLibrary( "CPUID.DLL" );
  57.   if( hCPUID )
  58.   {
  59.     pGetProcessorType = ( VOID ( WINAPI* )( LPSTR, LPSTR ) )GetProcAddress( hCPUID, "GetProcessorType" );
  60.     if( pGetProcessorType )
  61.     {
  62.       pGetProcessorType( szProcessorType, szCoprocessorType );
  63.       szTipoProcesador = szProcessorType;
  64.     }
  65.     FreeLibrary( hCPUID );
  66.   }
  67.  
  68.   return szTipoProcesador;
  69. }
  70.  
  71. const int TEstacionWindows::ObtenerDiscos( TStringList *ListaDiscos, TStringList *ListaTamanoDiscos )
  72. {
  73.   HANDLE hFile;
  74.   SECURITY_ATTRIBUTES SecAttr;
  75.   AnsiString szDrive, szNombreDrive;
  76.   int nDrives;
  77.   DISK_GEOMETRY InfoDrive;
  78.   DWORD dwBytesRetornados;
  79.   LARGE_INTEGER TamDrive;
  80.   bool bOK;
  81.  
  82.   nDrives = 0;
  83.   szDrive = "\\\\.\\PHYSICALDRIVE";
  84.   szDrive += nDrives;
  85.  
  86.   SecAttr.nLength = sizeof( SECURITY_ATTRIBUTES );
  87.   SecAttr.lpSecurityDescriptor = NULL;
  88.   SecAttr.bInheritHandle = false;
  89.  
  90.   hFile = CreateFile( szDrive.c_str( ), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL );
  91.   while( hFile != INVALID_HANDLE_VALUE )
  92.   {
  93.     bOK = DeviceIoControl( hFile, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, &InfoDrive, sizeof( DISK_GEOMETRY ), &dwBytesRetornados, NULL );
  94.  
  95.     if( bOK && ( InfoDrive.MediaType == FixedMedia ) )
  96.     {
  97.       szNombreDrive = "Drive";
  98.       szNombreDrive += nDrives;
  99.       TamDrive.QuadPart = ( InfoDrive.Cylinders.QuadPart * InfoDrive.TracksPerCylinder * InfoDrive.SectorsPerTrack * InfoDrive.BytesPerSector ) / 1048576;
  100.       ListaDiscos -> Add( szNombreDrive );
  101.       ListaTamanoDiscos -> Add( TamDrive.QuadPart );
  102.     }
  103.  
  104.     CloseHandle( hFile );
  105.     nDrives++;
  106.     szDrive = "\\\\.\\PHYSICALDRIVE";
  107.     szDrive += nDrives;
  108.     hFile = CreateFile( szDrive.c_str( ), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL );
  109.   }
  110.  
  111.   return nDrives;
  112. }
  113.  
  114. const int TEstacionWindows::ObtenerUnidades( TStringList *ListaUnidades, unsigned int nClaseUnidad )
  115. {
  116.   int nUnidades;
  117.   char szUnidades[ TAM_BUFFER_UNIDADES + 1 ];
  118.   char *szPosicion;
  119.  
  120.   nUnidades = 0;
  121.   ListaUnidades -> Clear( );
  122.   if( GetLogicalDriveStrings( TAM_BUFFER_UNIDADES, szUnidades ) )
  123.   {
  124.     szPosicion = szUnidades;
  125.     while( *szPosicion )
  126.     {
  127.       if( GetDriveType( szPosicion ) == nClaseUnidad )
  128.       {
  129.         ListaUnidades -> Add( szPosicion );
  130.         nUnidades++;
  131.       }
  132.       szPosicion += strlen( szPosicion ) + 1;
  133.     }
  134.   }
  135.  
  136.   return nUnidades;
  137. }
  138.  
  139.  
  140.  

La verdad ahora solo puedo ayudarte con esto...


Código: Text
  1.  
  2. //---------------------------------------------------------------------------
  3. #ifndef EstacionNTH
  4. #define EstacionNTH
  5.  
  6. #include <vcl/registry.hpp>
  7.  
  8. //---------------------------------------------------------------------------
  9. #define TAM_USUARIO 127
  10. #define TAM_BUFFER_UNIDADES 127
  11. #define TAM_NOMBRE_ESTACION 127
  12.  
  13. class TEstacionWindows
  14. {
  15.   private:
  16.     TRegistry *Registry;
  17.   public:
  18.     __fastcall TEstacionWindows( );
  19.     __fastcall ~TEstacionWindows( );
  20.     AnsiString __fastcall ObtenerVersionSO( );
  21.         AnsiString __fastcall ObtenerVersionExSO( );
  22.     AnsiString __fastcall ObtenerTipoProcesador( );
  23.     const int ObtenerDiscos( TStringList *ListaDiscos, TStringList *ListaTamanoDiscos );
  24.     const int ObtenerUnidades( TStringList *ListaUnidades, unsigned int nClaseUnidad );
  25. };
  26. #endif
  27.  
  28.  

y en alnterior es el .h :good:

Espero te sirva... y en cuanto a Win 98...mmm  ... :think:  no se si la sintaxis que utilicé para Win95 te sirva.. pero si algo mirate en la utilidades de la API como es..


Saludos :hola: