📄 diskspace.dpr
字号:
program diskspace;
{$APPTYPE CONSOLE}
Uses Sysutils;
var
free_size, total_size: Int64;
Drv: String;
Function GetDiskSize(drive: Char; var free_size, total_size: Int64): Boolean;
var
RootPath: array[0..4] of Char;
RootPtr: PChar;
current_dir: string;
begin
RootPath[0] := Drive;
RootPath[1] := ':';
RootPath[2] := '\';
RootPath[3] := #0;
RootPtr := RootPath;
current_dir := GetCurrentDir;
if SetCurrentDir(drive + ':\') then
begin
GetDiskFreeSpaceEx(RootPtr, Free_size, Total_size, nil);
// this to turn back to original dir
SetCurrentDir(current_dir);
Result := True;
end
else
begin
Result := False;
Free_size := -1;
Total_size := -1;
end;
end;
begin
Drv:=ParamStr(1);
If Drv='' Then
Drv:='c';
if GetDiskSize(Drv[1], free_size, total_size) then
Writeln('Free Space Left For Drive Drive: ',UpperCase(Drv),' ',IntToStr(free_size div 1024 div 1024),' Meg, Total Disk Space ',IntToStr(total_size div 1024 div 1024),' Meg')
else
Writeln('No disk in drive!');
// Insert user code here
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -