UNIT MainForm;
INTERFACE
USES
Windows, Messages, SysUtils, Classes, Forms, FileCtrl, Controls, StdCtrls;
CONST
MemoryLoad = 1; { Total memory used
in percents (%) }
TotalPhys = 2; {
Total physical memory in bytes }
AvailPhys = 3; {
Available physical memory (bytes) }
TotalPageFile = 4; { Total page file in (bytes) }
AvailPageFile = 5; { Available page file
(bytes) }
TotalVirtual = 6; { Total virtual
memory in bytes }
AvailVirtual = 7; { Available
virtual memory (bytes) }
CPU_Core1 = 2; {
binary mask for CORE 1 }
CPU_Core2 = 1; {
binary mask for CORE 2 }
TYPE
TfrmMain = class(TForm)
btnStart: TButton;
DriveCombo: TDriveComboBox;
lblHrdwHDD: TLabel;
lblSoftID: TLabel;
lblCpuId: TLabel;
lblMemoryStatus: TLabel;
lblCPUspeed: TLabel;
lblCpuThSpeed: TLabel;
lblCPUFamily: TLabel;
lblMemoryStatusMB: TLabel;
lblGetCPUVendor: TLabel;
procedure btnStartClick(Sender: TObject);
private
public
end;
VAR frmMain: TfrmMain;
{ FUNCTIONS IMPORTED FROM DLL: }
function GetCPUSpeed: Double; stdcall; external 'HardwareIDExtractor.DLL';
function CPUFamily : ShortString; stdcall; external 'HardwareIDExtractor.DLL'; { Get cpu identifier from the windows registry }
function GetCpuTheoreticSpeed: Integer; stdcall; external 'HardwareIDExtractor.DLL'; { Get cpu speed (in MHz) }
function IsCPUIDAvailable: Boolean; stdcall; external 'HardwareIDExtractor.DLL';
function GetCPUID (CpuCore: byte): ShortString; stdcall; external 'HardwareIDExtractor.DLL';
Function GetCPUVendor: ShortString; stdcall; external 'HardwareIDExtractor.DLL';
function MemoryStatus (MemType: Integer): cardinal; stdcall; external 'HardwareIDExtractor.DLL'; { in Bytes }
function MemoryStatus_MB (MemType: Integer): ShortString; stdcall; external 'HardwareIDExtractor.DLL'; { in MB }
function GetPartitionID (Partition: PChar): ShortString; stdcall; external 'HardwareIDExtractor.DLL'; { Get the ID of the specified patition. Example: 'C:' }
function GetIDESerialNumber(DriveNumber: Byte ): PChar; stdcall; external 'HardwareIDExtractor.DLL'; { DriveNr is from 0 to 4 }
implementation {$R *.DFM}
procedure TfrmMain.btnStartClick(Sender: TObject);
VAR sPath: PChar;
begin
{ HDD }
lblHrdwHDD.Caption:= 'IDE disk drive ID (hardware): '+ Trim(GetIdeSerialNumber(0));
if lblHrdwHDD.Caption = '' {
if disk 0 does not exist or it is something else (Flash, CDROM, etc) }
then lblHrdwHDD.Caption:= 'IDE disk drive ID (hardware): '+ Trim(GetIdeSerialNumber(1)); { get the ID of the next drive }
sPath:= PChar(DriveCombo.Drive + ':\');
lblSoftID.Caption:= 'Partition ID: '+ GetPartitionID(sPath);
{CPU} {
These functions are always available }
lblCPUFamily .Caption:= 'CPU Family: '+ CPUFamily;
lblGetCPUVendor.Caption:= 'CPU Vendor: '+ GetCPUVendor;
lblCpuThSpeed .Caption:= 'CPU Speed: ' + IntToStr(GetCpuTheoreticSpeed)+ ' MHz (theoretic)';
lblCPUspeed .Caption:= 'CPU Speed: ' + FloatToStr( GetCPUSpeed ) + ' MHz (current)';
{CPU-ID}
if IsCPUIDAvailable {
All modern CPU's should support this function. Probably nobody is using a Pentium I today :) }
then lblCpuId.Caption := 'CPU ID: '+ GetCPUID(CPU_Core1)
else lblCpuId.Caption := 'CPU ID not available.';
{RAM }
lblMemoryStatus .Caption:= 'RAM: '+IntToStr(MemoryStatus (TotalPhys))+ ' bytes'; { in Bytes }
lblMemoryStatusMB.Caption:= 'RAM: '+string(MemoryStatus_MB (TotalPhys))+ ' MB'; { in MB }
end;
end. |