GetDriveType detects "Google Drive" as DRIVE_FIXED... how to exclude them?

261 views Asked by At

I have a little utility (on beloved Delphi) that monitors HardDisks FreeSpace

I use GetDriveType

The problem is that "Google Drives" are being recognized as DRIVE_FIXED So I'm trying to manage how to identify this dirves, in order to exclude them... the workround so far is get drive name and find "google" in it's name.. but i think is not the clenest way.

procedure TFormSpace.CreaLabels;
var
    Type, i, n: Word;
    LblDummy: TLabel;
    Candidate: string;
begin
    Max:=0;
    i:=1;
    repeat
        Candidate:=chr(ord('c')+i-1) + ':\';
        Type:=GetDriveType(pchar(Candidate));
        if (Tipo=DRIVE_FIXED) then begin
            //Do something
        end;
        i:=i+1;
    until (i=MaxItems); 
end;

Thanks!

On an example setup:

c:\ -> 1TB SSD
d:\ -> 2TB SSD
f:\  -> Maped network drive
g:\ -> google drive, replicated con "d:\Drive"

the above code will return: C:\ D:\ G:\

But expected result is: C:\ D:\ (just real physical drives)

1

There are 1 answers

0
SullyPanda76cl On BEST ANSWER

The answer was the flag FILE_SUPPORTS_REMOTE_STORAGE (value 0x00000100)

A study can be seen here

or here here