type
TCPUID = array[1..4] of Longint;
TVendor = array [0..11] of char;
function GetCPUID : TCPUID; assembler; register;
asm
PUSH EBX {Save affected register}
PUSH EDI
MOV EDI,EAX {@Resukt}
MOV EAX,1
DW $A20F {CPUID Command}
STOSD {CPUID[1]}
MOV EAX,EBX
STOSD {CPUID[2]}
MOV EAX,ECX
STOSD {CPUID[3]}
MOV EAX,EDX
STOSD {CPUID[4]}
POP EDI {Restore registers}
POP EBX
end;
function GetCPUVendor : TVendor; assembler; register;
asm
PUSH EBX {Save affected register}
PUSH EDI
MOV EDI,EAX {@Result (TVendor)}
MOV EAX,0
DW $A20F {CPUID Command}
MOV EAX,EBX
XCHG EBX,ECX {save ECX result}
MOV ECX,4
@1:
STOSB
SHR EAX,8
LOOP @1
MOV EAX,EDX
MOV ECX,4
@2:
STOSB
SHR EAX,8
LOOP @2
MOV EAX,EBX
MOV ECX,4
@3:
STOSB
SHR EAX,8
LOOP @3
POP EDI {Restore registers}
POP EBX
end;
procedure TDemoForm.BitBtn1Click(Sender: TObject);
var
CPUID : TCPUID;
I : Integer;
S : TVendor;
begin
for I := Low(CPUID) to High(CPUID) do CPUID
:= -1;
CPUID := GetCPUID;
Label1.Caption := 'CPUID[1] = ' + IntToHex(CPUID[1],8);
Label2.Caption := 'CPUID[2] = ' + IntToHex(CPUID[2],8);
Label3.Caption := 'CPUID[3] = ' + IntToHex(CPUID[3],8);
Label4.Caption := 'CPUID[4] = ' + IntToHex(CPUID[4],8);
S := GetCPUVendor;
Label5.Caption := S;
end;
===========unit DiskInfo;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
type string1 = string[1];
type string30 = string[30];
type
TDiskInfo = class(TComponent)
private
FSectorsPerCluster WORD; // holds the sectors per cluster
FBytesPerSector WORD; // holds the bytes per sector
FFreeClusters WORD; // holds the number of free clusters
FClusters WORD; // holds the total number of disk clusters
FDiskFreeSpace WORD; // holds the total free space
FTotalDiskSpace WORD; // holds total disk capacity
FDrive :string1;
FDriveType :string30;
FVolumeName :string;
FSerialNumber :string;
FFileSystemType :string;
function GetDriveTyp :string30;
procedure SetDrive(value:string1);
protected
{ Protected declarations }
public
constructor create(AOwner:TComponent); override;
published
{ Published declarations }
property Drive :string1 read FDrive write setdrive;
property SectorsPerCluster WORD read FSectorsPerCluster;
property BytesPerSector WORD read FBytesPerSector;
property FreeClusters WORD read FFreeClusters;
property Clusters WORD read FClusters;
property DiskFreeSpace WORD read FDiskFreeSpace;
property TotalDiskSpace WORD read FTotalDiskSpace;
property DriveType :string30 read GetDriveTyp;
property VolumeName :string read FVolumeName;
property SerialNumber :string read FSerialNumber;
property FileSystemType :string read FFileSystemType;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Smart', [TDiskInfo]);
end;
constructor TDiskInfo.create(AOwner:TComponent);
begin
inherited create(AOwner);
setdrive('C');
end;
procedure TDiskInfo.SetDrive(value:string1);
var fulldrive :string[3];
tmp_drive :array[0..2] of char;
Tmp_SectorsPerCluster, // holds the sectors per cluster
Tmp_BytesPerSector, // holds the bytes per sector
Tmp_FreeClusters, // holds the number of free clusters
Tmp_Clusters WORD; // holds the total number of disk clusters
VolName :array[0..255] of Char; // holds the volume name
SerialNumber WORD; // holds the serial number
MaxCLength WORD; // holds the maximum file component length
FileSysFlag WORD; // holds file system flags
FileSysName :array[0..255] of Char; // holds the name of the file system
begin
fdrive:=value;
fulldrive:=value + ':/';
strpcopy(tmp_drive,fulldrive);
if GetDiskFreeSpace(tmp_drive,Tmp_SectorsPerCluster,Tmp_BytesPerSector,
Tmp_FreeClusters,Tmp_Clusters) then
begin
FSectorsPerCluster:=Tmp_SectorsPerCluster;
FBytesPerSector:=Tmp_BytesPerSector;
FFreeClusters:=Tmp_FreeClusters;
FClusters:=Tmp_Clusters;
FDiskFreeSpace:=Tmp_FreeClusters*Tmp_BytesPerSector*Tmp_SectorsPerCluster;
FTotalDiskSpace:=Tmp_Clusters*Tmp_BytesPerSector*Tmp_SectorsPerCluster;
end;
{retrieve the volumn information}
GetVolumeInformation(tmp_drive, VolName, 255, @SerialNumber, MaxCLength,
FileSysFlag, FileSysName, 255);
FVolumeName:=VolName;
FSerialNumber:=IntToHex(SerialNumber,8);
FFileSystemType:=FileSysName;
end;
function TDiskInfo.GetDriveTyp :string30;
var fulldrive :string[3];
tmp_drive :array[0..2] of char;
begin
fulldrive:=fdrive + ':/';
strpcopy(tmp_drive,fulldrive);
{retrieve the drive type}
case GetDriveType(tmp_drive) of
DRIVE_UNKNOWN :result:='No Type Information';
DRIVE_NO_ROOT_DIR :result:='Root Directory does not exist';
DRIVE_REMOVABLE :result:='Removable';
DRIVE_FIXED :result:='Fixed';
DRIVE_REMOTE :result:='Remote';
DRIVE_CDROM :result:='CDROM';
DRIVE_RAMDISK :result:='RamDisk';
end;
end;
end.