Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type
- TDriveType = (
- dtUnknown,
- dtNoRootDir,
- dtRemovable,
- dtFixed,
- dtRemote,
- dtCDROM,
- dtRAMDisk
- );
- TDriveTypes = set of TDriveType;
- procedure GetDriveList(Drives: TStrings; Filter: TDriveTypes = []);
- var
- P: PChar;
- Buffer: string;
- BufLen: Integer;
- begin
- BufLen := GetLogicalDriveStrings(0, nil);
- if BufLen > 0 then
- begin
- SetLength(Buffer, BufLen);
- if GetLogicalDriveStrings(Length(Buffer), PChar(Buffer)) = 0 then
- RaiseLastOSError;
- P := PChar(Buffer);
- while StrLen(P) > 0 do
- begin
- if (Filter = []) or (TDriveType(GetDriveType(P)) in Filter) then
- Drives.Add(P);
- P := StrEnd(P) + 1;
- end;
- end
- else
- RaiseLastOSError;
- end;
- // possible usage to list all drive types
- GetDriveList(ComboBox.Items);
- // possible usage to list fixed drive types
- GetDriveList(ComboBox.Items, [dtFixed]);
- // possible usage to list fixed and removable drive types
- GetDriveList(ComboBox.Items, [dtFixed, dtRemovable]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement