Welcome

首页 / 软件开发 / Delphi / delphi读取磁盘信息

delphi读取磁盘信息2012-01-151.读硬盘序列号

function GetDiskSerial(DiskChar: Char): string;

var

SerialNum : pdword;
a, b : dword;
Buffer : array [0..255] of char;
begin
result := "";
if GetVolumeInformation(PChar(diskchar+":"), Buffer, SizeOf(Buffer), SerialNum,
a, b, nil, 0) then
Result := IntToStr(SerialNum^);

end;

2.检查磁盘是否就绪

Function DiskReady(Root: string) : Boolean;

var

Oem : CARDINAL ;
Dw1,Dw2 : DWORD ;

begin

Oem := SetErrorMode( SEM_FAILCRITICALERRORS ) ;

if LENGTH(Root) = 1 then Root := Root + ":\" ;
Result := GetVolumeInformation( PCHAR( Root ), NIL,0,NIL, Dw1,Dw2, NIL,0 ) ;
SetErrorMode( Oem ) ;

end;