Welcome

首页 / 软件开发 / Delphi / Delphi调用WinAPI: GetLogicalDrives - 判断系统中存在的逻辑驱动器

Delphi调用WinAPI: GetLogicalDrives - 判断系统中存在的逻辑驱动器2012-04-02 cnblogs 万一//声明:GetLogicalDrives: DWORD; {无参数}
//返回值:
返回值的二进制右边第一位为 1 表示驱动器 A: 存在;
返回值的二进制右边第二位为 1 表示驱动器 B: 存在...以次类推.

//举 例:

procedure TForm1.FormCreate(Sender: TObject);
var
Drives: DWord;
i: Integer;
begin
Drives := GetLogicalDrives;
Memo1.Clear;
for i := 0 to 25 do {最多 26 个字母都用上}
if LongBool(Drives and ($0001 shl i)) = True then
Memo1.Lines.Add(Char(Ord("A")+i) + ":");
end;

//效果图: