⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 disk.pas

📁 取磁盘空间及驱动器类型.rar
💻 PAS
字号:
unit disk;

interface
uses
  Windows, Messages, SysUtils;
//取得驱动器总容量,剩余容量
procedure GetDiskSizeAvail(TheDrive : PChar;var TotalBytes : double;var TotalFree : double);
//取得驱动器类型
function GetDiskType(TheDrive : PChar): string;

implementation
procedure GetDiskSizeAvail(TheDrive : PChar;var TotalBytes : double;var TotalFree : double);
var
  AvailToCall : int64;
  TheSize : int64;
  FreeAvail : plargeinteger;
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; 

function GetDiskType(TheDrive : PChar): string;
var
  x:integer;
begin
  x := GetDriveType(TheDrive);
  Case x of
    2: result := '可移动驱动器';
    3: result := '固定驱动器';
    4: result := '网络驱动器';
    5: result := 'CD-ROM驱动器';
    6: result := '虚拟驱动器';
    Else result := '驱动器无效';
  End;
end;
end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -