Delphi is increasingly favored by programming enthusiasts for its excellent visual programming, flexible Windows API interface, and rich underlying operations.
In Delphi, by calling Windows API, you can easily obtain system information, which helps us write better Windows applications. The following program is compiled and passed under Delphi3.0 For Windows 9x.
1. Use the GetDriveType function to obtain disk information
Lbl_DriveType:Tlabel;
DriveType:Word; //Define drive type variable
DriveType:=GetDriveType(RootPathName); //Get the disk drive information corresponding to RootPathName
case DriveType of
DRIVE_REMOVABLE:Lbl_DriveType.Caption:= 'Floppy disk drive';
DRIVE_FIXED : Lbl_DriveType.Caption:= 'Hard drive';
DRIVE_REMOTE: Lbl_DriveType.Caption:= 'Network drive';
DRIVE_CDROM: Lbl_DriveType.Caption:= 'CD drive';
DRIVE_RAMDISK: Lbl_DriveType.Caption:= 'Memory virtual disk';
end; //Display the disk information in Lbl_DriveType
2. Use the GlobalMemoryStatus function to obtain memory usage information
MemStatus: TMEMORYSTATUS; //Define memory structure variables
Lbl_Memory:Tlabel;
MemStatus.dwLength := size of(TMEMORYSTATU??
S);
GlobalMemoryStatus(MemStatus); //Return memory usage information
Lbl_Memory.Caption := format('Total memory: %d KB Available memory: %dKB',[MemStatus.dwAvailPhys div 1024,MemStatus.dwTotalPhys div 1024]);
//Display memory information in Lbl_Memory
3. Use GetSystemInfo function to obtain CPU information
SysInfo: TSYSTEMINFO;
Lbl_CPUName:Tlabel;
GetSystemInfo(SysInfo);//Get CPU information
case SysInfo.dwPRocessorType of
PROCESSOR_INTEL_386:Lbl_CPUName.Caption:=format('%d%s',[SysInfo.dwNumber Of Processors,'Intel80386']);
PROCESSOR_INTEL_486:Lbl_CPUName.Caption:=format('%d%s',[SysInfo.dwNumber Of Processors, 'Intel 80486']);
PROCESSOR_INTEL_PENTIUM:Lbl_CPUName.Caption:=format('%d%s',[SysInfo.dwNum
berOfProcessors, 'Intel Pentium']);
PROCESSOR_MipS_R4000:Lbl_CPUName.Caption:=format('%d%s',[SysInfo.dwNumberOfProcessors, 'MIPS R4000']);
PROCESSOR_ALPHA_21064:Lbl_CPUName.Caption:=format('%d%s',[SysInfo.dwNumberOfProcessors, 'ALPHA 21064']);
end;//Display the CPU information in Lbl_CPUName.