Delphi调用WinAPI: GetDiskFreeSpace

//声明:GetDiskFreeSpace(
 lpRootPathName: PChar;       {磁盘根路径}
 var lpSectorsPerCluster: DWORD;  {一个簇内的扇区数}
 var lpBytesPerSector: DWORD;    {一个扇区内的字节数}
 var lpNumberOfFreeClusters: DWORD; {剩余簇数}
 var lpTotalNumberOfClusters: DWORD {总簇数}
): BOOL;

//举例:

procedure TForm1.FormCreate(Sender: TObject);
var
 d1,d2,d3,d4: DWORD;
begin
 GetDiskFreeSpace('C:',d1,d2,d3,d4);
 {以下只是显示}
 Memo1.Clear;
 with Memo1.Lines do
 begin
  Add(Format('一个簇内的扇区数: %d',[d1]));
  Add(Format('一个扇区内的字节数: %d',[d2]));
  Add(Format('剩余簇数: %d',[d3]));
  Add(Format('总簇数: %d',[d4]));
  Add(Format('剩余空间: %f GB',[d3/1024/1024/1024*d2*d1]));
  Add(Format('总空间: %f GB',[d4/1024/1024/1024*d2*d1]));
 end;
end;

//效果图:

时间: 2024-09-11 04:38:11

Delphi调用WinAPI: GetDiskFreeSpace的相关文章

Delphi调用WinAPI: MessageBeep

//声明: MessageBeep( uType: UINT {参数是个常数; 根据不同的常数发出不同的声音, 也就是调用了不同的 wav} ): BOOL; //参数 uType 可选值: MB_OK = 0; MB_ICONHAND = 16; MB_ICONQUESTION = 32; MB_ICONEXCLAMATION = 48; MB_ICONASTERISK = 64; //举例, 下面代码会发出错误警告 begin MessageBeep(16); end; //另外 Delph

Delphi调用WinAPI 字符及字符串函数(14): CharToOem、OemToChar

CharToOemBuff.OemToCharBuff 与 CharToOem.OemToChar 的区别只是前者可以指 定要转换的字符数.unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; Button2: TButt

Delphi调用WinAPI 字符及字符串函数(13)

lstrcmp.lstrcmpi - 对比串 lstrcmp 区分大小写; lstrcmpi 不区分大小写. 返回值: -1.0.1, 其中 0 表示相 同. unit Unit1;interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; Butto

Delphi调用WinAPI 字符及字符串函数(12): lstrlen

unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; Button2: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Se

Delphi调用WinAPI 字符及字符串函数(11)

lstrcpyn - 复制字符串, 同时指定要复制的长度 unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); end; var Form1

Delphi调用WinAPI 字符及字符串函数(10)

lstrcpy - 复制字符串 unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; Button2: TButton; Button3: TButton; procedure Button1Click(Sender: T

Delphi调用WinAPI 字符及字符串函数(9)

lstrcat - 合并字符串 unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; Button2: TButton; Button3: TButton; Button4: TButton; procedure Butt

Delphi调用WinAPI 字符及字符串函数(1)

CharLower - 字符或字符串转小写 unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; Button2: TButton; Button3: TButton; Button4: TButton; Button5:

Delphi调用WinAPI: QueryPerformanceCounter

//声明:QueryPerformanceCounter( var lpPerformanceCount: TLargeInteger {获取定时器每秒的频率数; TLargeInteger = Int64} ): BOOL; {返回 False 表示调用失败, 或者是硬件不支持高性能定时器} // 一个有趣的示例: 判断你的鼠标点击速度; 我的最快记录是 151 毫米 var n1,n2,n,f: Int64; b: Boolean; procedure TForm1.FormMouseDow