Free desktop tools and utilities for Windows. Download our software now.Free desktop tools and utilities for Windows. Download our software now.
HomeContact
molecular biology software
scf trace assembly

Hardware ID Extractor DLL for Delphi/Pascal programmers
Source code examples

Hardware unique ID extractor

 

 

free software

 

 

 

 

 

 

This DLL is for Delphi/Pascal programmers (HardwareIDExtractorPas.DLL)

Delphi users can retrieve the hardware ID (for example CPU ID) with a single line of code like this: ShowMessage('CPU ID is: '+ GetCpuID)

 

Non-Delphi programmers (.Net, Visual Basic,Visual Fox Pro, Libert Basic, etc) read here.


Minimal source code demo for Delphi/Lazarus/Free Pascal programmers

 

In DPR file:
  
  Uses FastShareMem; 

In PAS file:
          
          Interface
          
          function CPUFamily: String; external 'HardwareIDExtractorPas.DLL';
          
          
          Implementation
          
          procedure Button1ClickExecute(Sender: TObject);
          begin
          Label1.Caption:= CPUFamily;
          end;
 

Full projects:

 


 

 

DLL exported functions

 

 

CONSTANTS

{ OSMemType used by SystemMemStatus }


mMemoryLoad = 1; { Total memory used in percents (%) }
mTotalPhys = 2; { Total physical memory in bytes }
mAvailPhys = 3; { Available physical memory (bytes) }
mTotalPageFile = 4; { Total page file in (bytes) }
mAvailPageFile = 5; { Available page file (bytes) }
mTotalVirtual = 6; { Total virtual memory in bytes }
mAvailVirtual = 7; { Available virtual memory (bytes) }

 

{ ProcMemType used by ProcessMemStatus }


pWorkingSetSize =1; {- the current working set size, in bytes. }
pPageFaultCount =2; {- the number of page faults.}
pPeakWorkingSetSize =3; {- the peak working set size, in bytes.}
pQuotaPeakPagedPoolUsage =4; {- The peak paged pool usage, in bytes.}
pQuotaPagedPoolUsage =5; {- The current paged pool usage, in bytes.}
pQuotaPeakNonPagedPool =6; {- The peak nonpaged pool usage, in bytes.}
pQuotaNonPagedPoolUsg =7; {- The current nonpaged pool usage, in bytes.}
pPageFileUsage =8; {- The current space allocated for the pagefile, in bytes. Those pages may or may not be in memory.}
pPeakPagefileUsage =9; {- The peak space allocated for the pagefile, in bytes.}

 

TB = 1099511627776;
GB = 1073741824;
MB = 1048576; { 1024*1024 = 1048576 }
KB = 1024;

 

{ CPU }
function CPUFamily : String; { Get cpu identifier from the windows registry }
function GetCPUVendor : String; { GetCPUVendor function }
function GetCPUSpeed (CONST SomeDelay: Integer= 50): Double; { The higher the delay, the accurate the result. Default= 200ms }
function IsIntel64BitCPU : Boolean; { Detects IA64 processors }
function GetCpuTheoreticSpeed: Integer; { Get cpu speed (in MHz) }
function IsCPUIDAvailable : Boolean;
function GetCPUID (CoreMask: Word): String; { Get the ID of the specified physical core }
function GetCpuIdNow : String; { Get the ID of the first available core }
function GetCPUCount : Integer; { The number of LOGICAL processors in the current group }

 

{ SYSTEM RAM }
function SystemMemStatus (CONST OSMemType : Byte): Cardinal; { in Bytes. Limited by the capacity of the OS (32bits OSs will report max 2 or 3 GB) }
function SystemMemStatus_KB (CONST OSMemType : Byte): String; { in KB }
function SystemMemStatus_MB (CONST OSMemType : Byte): String; { in MB }

{ PROCESS RAM }
function ProcessMemStatus (CONST ProcMemType: Byte= 1): Cardinal; { Returns data about the memory used of the current process }
function ProcessPeakMem: string; { Shows the highest amount of memory this program ever occupied }
function ProcessCurrentMem: string;

 

{ VIRTUAL RAM }
function GetPageSize: Cardinal; { The page size and the granularity of page protection and commitment. This is the page size used by the VirtualAlloc function. }
function GetMemGranularity: Integer; { Granularity with which virtual memory is allocated (in KB) }

 

{ RAM - Advanced stuff }
function GetLowAddr: Cardinal; { Lowest RAM memory address accessible to applications (this is the RAM address, not virtual memory address) }
function GetHiAddr: Cardinal; { Lowest RAM memory address accessible to applications }
procedure TrimWorkingSet; { Minimizes the amount to RAM used by application by swapping the unused pages back to disk }

 

{ HDD }
function GetPartitionID (Partition : string): String; { Get the ID of the specified patition. Example of parameter: 'C:' }
function GetIDESerialNumber(DriveNumber: Byte): AnsiString; { DriveNr starts from 0 (for the first drive) }

 

{ BIOS (NEW!) }
function BiosDate: string;
function BiosVersion: string; { Could be something like: TOSQCI - 6040000 Ver 1.00PARTTBL. TOS is from Toshiba, Q is comming from product series (Qosmio) }
function BiosProductID: string; { Manufacturer product (laptop, PC) ID - Could be something like: Toshiba_PQX33U-01G00H }
function BiosVideo: string;

 

{ UTILS }
function GenerateHardwareReport: string;
procedure Mes (CONST sMessage: string); { Lightweight replacement for Dialogs.Pas }
function FormatBytes (CONST Size: Int64; CONST Decimals: Integer): string; { Format bytes to KB, MB, GB, TB }
function BinToInt (Value: String): Integer; {Utility. Convers a string representing a binary value '110101010' to integer }
function IntToBin (CONST Value, Digits: integer): String; {Utility. Convers an integer to its binary representation such as '110101010' }
function CoreNumber2CoreMask(CoreNo: integer): integer; {Utility function that can be used as parameter for 'GetCPUID' }
procedure ChangeByteOrder(VAR Data; Size : Integer);
function GetDllVersion: Real;

 


 


 

The following functions are freely accessible (you don't need a to purchase the DLL in order to use them):

  • ChangeByteOrder
  • IntToBin
  • CoreNumber2CoreMask
  • WindowsProductID
  • GetPageSize
  • GetMemGranularity
  • GetLowAddr
  • GetHiAddr
  • SystemMemStatus
  • ProcessCurrentMem
  • ProcessPeakMem
  • IsCPUIDAvailable
  • GetCPUSpeed
  • GetCPUCount
  • IsIntel64BitCPU
  • GetDllVersion
  • ReleaseMemory  

IMPORTANT: Delphi users MUST add the FastShareMem unit to your 'uses' clause in the DPR file. The unit must be the first one listed. FastShareMem replaces Borland's ShareMem.DLL which is very good because don't have to deliver also Borland's ShareMem.DLL with your application. See the examples provided for details.      

 

contig assembly software

Hardware ID Extractor