Quick Tip: Is a Drive Hidden From Windows Explorer (Using NoDrives Registry Entry)

The “NoDrives” Registry entry allows to hide a drive (/drives) you do not want to get displayed by Windows Explorer and/or from the standard Open Dialog box. Here’s how to programmatically check if a drive is hidden using Delphi.


Say you have a mapped network drive that points to your encrypted files – and you do not want such a drive to appear in Open dialogs nor in Windows Explorer. Or, you have a floppy disk drive (a relic today, younglings might not know what that is) and you want it hidden from My Computer (as you are really no longer using it).

Using the “NoDrives” entry under “HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer” you can specify what drives you want to hide. Here’s how to do it: Hide Drives from Your Computer and here’s a nice NoDrives Calculator.

Now, drives hidden in such a way would still be accessible from command prompt and you can still manually browse to hidden drives in Windows Explorer by directly typing in the path to the hidden drive.

Say you want to hide drives A and M. The binary value for NoDrives would be 1000000000001 which is 4097 decimal.

In any case, if you need to programmatically check if a drive is hidden from Windows Explorer, here’s how:

function DriveHiddenInNoDrives(const driveLetter : Char): boolean;
  noDrivesRegValue, driveBinValue : integer;
  result := false;
  with TRegistry.Create do
    if OpenKeyReadOnly('\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\') then
      noDrivesRegValue := ReadInteger('NoDrives');

      //for E drive this is 2^4 == 1000 == 16 decimal
      //since Ord('E') = 69 and Ord('A') = 65, 69 - 65 = 4
      //1 shl 4 == 2^4 == 16
      driveBinValue := (1 shl (Ord(UpCase(driveLetter)) - Ord('A')));

      //if drives A and E are hidden, the noDrivesRegValue value is 17 == 10001 binary
      //so is 16 "in" 17? It is, since 17 = 16 + 1, unique sum of powers of 2
      result :=  driveBinValue AND noDrivesRegValue <> 0;


The DriveHiddenInNoDrives opens up the registry database (using TRegistry), gets the NoDrives value from the correct location. Returns true if the “driveLetter” drive is included in “noDrivesRegValue”.

You would simply call this function like:

if DriveHiddenInNoDrives(‘E’) then 
  ShowMessage(‘E drive is hidden’);

if NOT DriveHiddenInNoDrives(‘C’) then 
  ShowMessage(‘C drive is NOT hidden’);

That’s it.

Why would you need this? We’ll, if using TShellTreeView and trying to access a hidden drive using the Path property you will get an AV. More on that soon ….

Leave a Reply

Your email address will not be published. Required fields are marked *