AnsiString __fastcall TEstacionWindows::ObtenerVersionExSO( )
{
AnsiString szVersionSO;
OSVERSIONINFO VersionSO;
VersionSO.dwOSVersionInfoSize = sizeof( OSVERSIONINFO );
if( GetVersionEx( &VersionSO ) )
{
switch( VersionSO.dwPlatformId )
{
case VER_PLATFORM_WIN32s:
szVersionSO = "Win32 on Windows 3.1 Versión ";
break;
case VER_PLATFORM_WIN32_WINDOWS:
szVersionSO = "Windows 95 Versión ";
break;
case VER_PLATFORM_WIN32_NT:
if( VersionSO.dwMajorVersion >= 5 )
{
szVersionSO = "Windows 2000 Versión ";
}
else
{
szVersionSO = "Windows NT Versión ";
}
break;
default:
szVersionSO = "Sistema Desconocido ";
}
szVersionSO += VersionSO.dwMajorVersion;
szVersionSO += ".";
szVersionSO += VersionSO.dwMinorVersion;
szVersionSO += " ";
szVersionSO += VersionSO.szCSDVersion;
szVersionSO += " Build ";
szVersionSO += VersionSO.dwBuildNumber;
}
return szVersionSO;
}
AnsiString __fastcall TEstacionWindows::ObtenerTipoProcesador( )
{
AnsiString szTipoProcesador;
HANDLE hCPUID;
VOID ( WINAPI *pGetProcessorType )( LPSTR, LPSTR );
char szProcessorType[ 255 ], szCoprocessorType[ 255 ];
szTipoProcesador = "";
memset( szProcessorType, 0, 255 );
memset( szCoprocessorType, 0, 255 );
hCPUID = LoadLibrary( "CPUID.DLL" );
if( hCPUID )
{
pGetProcessorType = ( VOID ( WINAPI* )( LPSTR, LPSTR ) )GetProcAddress( hCPUID, "GetProcessorType" );
if( pGetProcessorType )
{
pGetProcessorType( szProcessorType, szCoprocessorType );
szTipoProcesador = szProcessorType;
}
FreeLibrary( hCPUID );
}
return szTipoProcesador;
}
const int TEstacionWindows::ObtenerDiscos( TStringList *ListaDiscos, TStringList *ListaTamanoDiscos )
{
HANDLE hFile;
SECURITY_ATTRIBUTES SecAttr;
AnsiString szDrive, szNombreDrive;
int nDrives;
DISK_GEOMETRY InfoDrive;
DWORD dwBytesRetornados;
LARGE_INTEGER TamDrive;
bool bOK;
nDrives = 0;
szDrive = "\\\\.\\PHYSICALDRIVE";
szDrive += nDrives;
SecAttr.nLength = sizeof( SECURITY_ATTRIBUTES );
SecAttr.lpSecurityDescriptor = NULL;
SecAttr.bInheritHandle = false;
hFile = CreateFile( szDrive.c_str( ), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL );
while( hFile != INVALID_HANDLE_VALUE )
{
bOK = DeviceIoControl( hFile, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, &InfoDrive, sizeof( DISK_GEOMETRY ), &dwBytesRetornados, NULL );
if( bOK && ( InfoDrive.MediaType == FixedMedia ) )
{
szNombreDrive = "Drive";
szNombreDrive += nDrives;
TamDrive.QuadPart = ( InfoDrive.Cylinders.QuadPart * InfoDrive.TracksPerCylinder * InfoDrive.SectorsPerTrack * InfoDrive.BytesPerSector ) / 1048576;
ListaDiscos -> Add( szNombreDrive );
ListaTamanoDiscos -> Add( TamDrive.QuadPart );
}
CloseHandle( hFile );
nDrives++;
szDrive = "\\\\.\\PHYSICALDRIVE";
szDrive += nDrives;
hFile = CreateFile( szDrive.c_str( ), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL );
}
return nDrives;
}
const int TEstacionWindows::ObtenerUnidades( TStringList *ListaUnidades, unsigned int nClaseUnidad )
{
int nUnidades;
char szUnidades[ TAM_BUFFER_UNIDADES + 1 ];
char *szPosicion;
nUnidades = 0;
ListaUnidades -> Clear( );
if( GetLogicalDriveStrings( TAM_BUFFER_UNIDADES, szUnidades ) )
{
szPosicion = szUnidades;
while( *szPosicion )
{
if( GetDriveType( szPosicion ) == nClaseUnidad )
{
ListaUnidades -> Add( szPosicion );
nUnidades++;
}
szPosicion += strlen( szPosicion ) + 1;
}
}
return nUnidades;
}