Sinisterly
[Source] Get list of drives in Windows - Printable Version

+- Sinisterly (https://sinister.ly)
+-- Forum: Coding (https://sinister.ly/Forum-Coding)
+--- Forum: Python (https://sinister.ly/Forum-Python)
+--- Thread: [Source] Get list of drives in Windows (/Thread-Source-Get-list-of-drives-in-Windows)



[Source] Get list of drives in Windows - Psycho_Coder - 04-10-2015

The thread title is self-explanatory and so is the code. Nothing much to explain.

Code:
import string from ctypes import windll def get_drives(): drive_list = [] bitmask = windll.kernel32.GetLogicalDrives() for letter in iter(string.letters[len(string.letters)/2:]): if bitmask & 1: drive_list.append(letter) bitmask >>= 1 return drive_list if __name__ == '__main__': print(get_drives())