//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
#include "shellapi.h"
#include "stdlib.h"
#include "stdio.h"
#include "windows.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
bool WindowsVersion(char *os, char *version, char *other);
int ProcessorInfo(bool NT, char *processor);
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
bool WindowsVersion( char *os, char *version, char *other)
{
bool NT = false;
OSVERSIONINFO version_info;
version_info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&version_info);
if(version_info.dwMajorVersion < 4)
{
}
else
{
sprintf(version
, "%d.%d.%04d", version_info.
dwMajorVersion, version_info.
dwMinorVersion, version_info.
dwBuildNumber); }
switch(version_info.dwPlatformId)
{
case VER_PLATFORM_WIN32s:
sprintf(os
, "%s", "Microsoft Win32s"); break;
case VER_PLATFORM_WIN32_WINDOWS:
sprintf(os
, "%s", "Microsoft Windows 95/98"); break;
case VER_PLATFORM_WIN32_NT:
NT = true;
switch(version_info.dwMajorVersion)
{
case 4: sprintf(os
, "%s", "Microsoft Windows NT"); break; case 5: sprintf(os
, "%s", "Microsoft Windows 2000"); break; case 6: sprintf(os
, "%s", "Microsoft Windows XP"); break; default :
sprintf(os
, "%s", "Microsoft Windows ??"); }
break;
default :
sprintf(os
, "%s", "Microsoft Windows ??"); }
sprintf(os
, "%s", version_info.
szCSDVersion); return NT;
}
//---------------------------------------------------------------------------
int ProcessorInfo(bool NT, char *processor)
{
SYSTEM_INFO sys_info;
AnsiString Processor;
AnsiString Level;
GetSystemInfo(&sys_info);
int value;
if(NT == true)
{
switch(sys_info.wProcessorArchitecture)
{
case PROCESSOR_ARCHITECTURE_INTEL :
Processor = "Intel";
switch(sys_info.wProcessorLevel)
{
case 3 : Level = "80386";break;
case 4 : Level = "80486";break;
case 5 : Level = "Pentium"; break;
case 6 :
value = HIBYTE(sys_info.wProcessorRevision);
ShowMessage(value);
switch(value)
{
case 1 : Level = "Pentium PRO";
Form1->Shape1->Brush->Color = clRed;
Form1->Label17->Caption = "LOW";
break;
case 3,5 : Level = "Pentium II";
Form1->Shape1->Brush->Color = clRed;
Form1->Label17->Caption = "LOW";
break;
case 6 : Level = "Celeron";
Form1->Shape1->Brush->Color = clRed;
Form1->Label17->Caption = "LOW";
break;
case 7,8,10,11 : Level = "Pentium III";
Form1->Shape1->Brush->Color = clYellow;
Form1->Label17->Caption = "MEDIUM";
break;
}
break;
case 15 : Level = "Pentium 4";
Form1->Shape1->Brush->Color = clGreen;
Form1->Label17->Caption = "HIGH";
break;
default : Level = "Unknown";
}
break;
}
}
else //win 9x
{
switch(sys_info.dwProcessorType)
{
case PROCESSOR_INTEL_386 :
Processor = "Intel"; Level = "80386"; break;
case PROCESSOR_INTEL_486 :
Processor = "Intel"; Level = "80486"; break;
case PROCESSOR_INTEL_PENTIUM :
Processor = "Intel"; Level = "Pentium"; break;
default : Processor = "N/A";
}
}
sprintf(processor
, "%s %s", Processor.
c_str(), Level.
c_str()); return sys_info.dwNumberOfProcessors;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::BitBtn1Click(TObject *Sender)
{
Application->Terminate();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
//Populate the Form
//Get User
char name[255];
DWORD size = 255;
GetUserName(name, &size); //Win32 API Call
Label2->Caption = AnsiString(name);
//Get OS Version
char os[255];
char version[255];
char patch[255];
bool NT = WindowsVersion(os, version, patch); //Win32 API Wrapper
Label4->Caption = AnsiString(os);
Label6->Caption = AnsiString(version);
//get the Processor Information
char processor[MAX_PATH];
Label12->Caption = ProcessorInfo(NT, processor);
Label10->Caption = AnsiString(processor);
//Get Memory Now
MEMORYSTATUS memory;
memory.dwLength = sizeof(memory);
GlobalMemoryStatus(&memory);
Label14->Caption = IntToStr((memory.dwTotalPhys/1024)/1024)+" KB";
//Get HDD Space
AnsiString Drive = AnsiString("C:\\");
DWORD spc = 0;
DWORD bps = 0;
DWORD cluster = 0;
DWORD freecluster = 0;
GetDiskFreeSpace(Drive.c_str(), &spc, &bps, &freecluster, &cluster);
unsigned long v1 = (unsigned long)cluster;
unsigned long v2 = (unsigned long)spc;
unsigned long v3 = (unsigned long)bps;
unsigned long volsize = (v1 * v2)/1024 * v3;
String vol = (volsize/1024);
vol = vol.SubString(0,2);
if(volsize > 0)
{
Label16->Caption = IntToStr((volsize/1024)/1024) + "." + vol + " GB";
}
else
{
Label16->Caption = "n/a";
}
}
//---------------------------------------------------------------------------