How detect if mapped network drive is disconnected using IShellFolder?

1k views Asked by At

I am using the IShellFolder interface to enumermate the Shell namespace objects. Doing this I am getting my mapped network drives, of which some are connected and available and others are not.

I would to know how I can detect whether or not a particular mapped drive is available. Is there some method, shell function or attribute that I can use?

I am using IShellFolder.GetAttributesOf() method to get various attributes on the drive, but do not see anything there that would indicate this.

1

There are 1 answers

0
Jonathan Potter On

If a mapped drive is disconnected it will not appear in the bitmask returned by the GetLogicalDrives function.

For example,

wchar_t wchDriveLetter = L'P'; // example
int iDriveNumber = towupper(wchDriveLetter) - L'A';
bool fIsDisconnected = ( GetLogicalDrives() & ( 1 << iDriveNumber ) ) == 0;