delphi获取大于2g硬盘的容量

时间:2010-01-26 14:50:19  来源:第二电脑网  作者:第二电脑网

  第二电脑网导读:rnal kernel32name 'GetDiskFreeSpaceExA';procedure GetDiskSizeAvail(TheDrive : PChar;var TotalBytes : double;var TotalFree : double);varAvailToCall : integer;TheSize : integer;FreeAvail : integer;begin  GetDiskFreeSpaceEx(TheDrive,  AvailToCall,  ...
  正文:

function GetDiskFreeSpaceEx(lpDirectoryName: PAnsiChar;
var lpFreeBytesAvailableToCaller : Integer;
var lpTotalNumberOfBytes: Integer;
var lpTotalNumberOfFreeBytes: Integer) : bool;
stdcall;
external kernel32
name 'GetDiskFreeSpaceExA';


procedure GetDiskSizeAvail(TheDrive : PChar;
var TotalBytes : double;
var TotalFree : double);
var
AvailToCall : integer;
TheSize : integer;
FreeAvail : integer;
begin
  GetDiskFreeSpaceEx(TheDrive,
  AvailToCall,
  TheSize,
  FreeAvail);
  {$IFOPT Q+}
  {$DEFINE TURNOVERFLOWON}
  {$Q-}
  {$ENDIF}
  if TheSize >= 0 then
  TotalBytes := TheSize else
  if TheSize = -1 then begin
    TotalBytes := $7FFFFFFF;
    TotalBytes := TotalBytes * 2;
    TotalBytes := TotalBytes + 1;
  end else
  begin
    TotalBytes := $7FFFFFFF;
    TotalBytes := TotalBytes + abs($7FFFFFFF - TheSize);
  end;
  
  if AvailToCall >= 0 then
  TotalFree := AvailToCall else
  if AvailToCall = -1 then begin
    TotalFree := $7FFFFFFF;
    TotalFree := TotalFree * 2;
    TotalFree := TotalFree + 1;
  end else
  begin
    TotalFree := $7FFFFFFF;
    TotalFree := TotalFree + abs($7FFFFFFF - AvailToCall);
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
TotalBytes : double;
TotalFree : double;
begin
  GetDiskSizeAvail('C:',
  TotalBytes,
  TotalFree);
  ShowMessage(FloatToStr(TotalBytes));
  ShowMessage(FloatToStr(TotalFree));
end;

"delphi获取大于2g硬盘的容量"由第二电脑网原创提供,转载请注明:http://www.002pc.com/master/College/Language/Delphi/2010-01-26/12433.html


关键字:

关于《delphi获取大于2g硬盘的容量》文章的评论

站内搜索: 高级搜索

热门搜索: Windows style 系统 tr IP QQ CPU 安装 function 注册 if td