Looking for a reliable way to determine if a drive letter is in use
#1
I'm looking for a reliable way to determine if a drive letter is in use but I'm running into some difficulties.

Take the following small clip as an example:

A$ = "F:\"
If _DirExists(A$) Then
    Print A$; " Exists"
Else
    Print A$; "Does not exist"
End If

Normally, this works fine and indicates if the drive letter contained in A$ exists. But now consider these two exceptions:

1) Suppose I have a thumbdrive attached to the system that has been wiped clean. By wiped clean, I mean you open DISKPART, select the thumbdrive, and perform a "CLEAN" on that drive. In this instance, there will be no partitions on the drive, but in File Explorer, the drive still shows up with a drive letter. However, the clip above will indicate that this drive letter does NOT exist. As a result, if I try to assign that drive letter to another drive, it will fail because it is already in use.

2) The same thing happens if I connect a drive that has BitLocker encryption but has not yet been unlocked. The QB64PE code will indicate that the drive letter does not exist even though it is already in use.

Any suggestions on a better way to determine if a drive letter is in use?
Reply


Messages In This Thread
Looking for a reliable way to determine if a drive letter is in use - by hanness - 05-08-2023, 03:46 PM



Users browsing this thread: 5 Guest(s)