信息获取的一般过程是什么 使用Delphi获取系列信息
使用Delphi获取系列信息
Delphi以其优良的可视化编程 灵活的Windows API接口 丰富的底层操作越来越受到编程爱好者的青睐在Delphi中 通过调用Windows API 可以很方便地获取系统信息 这有助于我们编写出更好的Windows应用程序 以下程序在Delphi For Windows x下编译通过
一 用GetDriveType函数获取磁盘信息
Lbl_DriveType:Tlabel;
DriveType:WORD; //定义驱动器类型变量
DriveType:=GetDriveType(RootPathName); //获得RootPathName所对应的磁盘驱动器信息
case DriveType of
DRIVE_REMOVABLE:Lbl_DriveType Caption:= 软盘驱动器 ;
DRIVE_FIXED : Lbl_DriveType Caption:= 硬盘驱动器 ;
DRIVE_REMOTE: Lbl_DriveType Caption:= 网络驱动器 ;
DRIVE_CDROM: Lbl_DriveType Caption:= 光盘驱动器 ;
DRIVE_RAMDISK: Lbl_DriveType Caption:= 内存虚拟盘 ;
end; //将该磁盘信息显示在Lbl_DriveType中
二 用GlobalMemoryStatus函数获取内存使用信息
MemStatus: TMEMORYSTATUS; //定义内存结构变量
Lbl_Memory:Tlabel;
MemStatus dwLength := size of(TMEMORYSTATU
S);
GlobalMemoryStatus(MemStatus); //返回内存使用信息
Lbl_Memory Caption := format( 共有内存: %d KB 可用内存: %dKB [MemStatus dwAvailPhys div MemStatus dwTotalPhys div ]);
//将内存信息显示在Lbl_Memory中
三 用GetSystemInfo函数获取CPU信息
SysInfo: TSYSTEMINFO;
Lbl_CPUName:Tlabel;
GetSystemInfo(SysInfo);//获得CPU信息
case SysInfo dwProcessorType of
PROCESSOR_INTEL_ :Lbl_CPUName Caption:=format( %d%s [SysInfo dwNumber Of Processors Intel ]);
PROCESSOR_INTEL_ :Lbl_CPUName Caption:=format( %d%s [SysInfo dwNumber Of Processors Intel ]);
PROCESSOR_INTEL_PENTIUM:Lbl_CPUName Caption:=format( %d%s [SysInfo dwNum

berOfProcessors Intel Pentium ]);
PROCESSOR_MIPS_R :Lbl_CPUName Caption:=format( %d%s [SysInfo dwNumberOfProcessors MIPS R ]);
PROCESSOR_ALPHA_ :Lbl_CPUName Caption:=format( %d%s [SysInfo dwNumberOfProcessors ALPHA ]);
lishixinzhi/Article/program/Delphi/201311/8514