Name/ID of removable Media: how?
Claudio Grondi
claudio.grondi at freenet.de
Tue Apr 19 08:46:56 EDT 2005
There are sure thousand ways
of doing it "with windoze".
Here one of them (NOT tested) in form
of code snippets you can rearrange
for your purpose:
import win32com.client
axFSO = win32com.client.Dispatch("Scripting.FileSystemObject") # SCRRUN.DLL
axLstDrives = axFSO.Drives
dctAXaxFSO_NumCodeAsKeyVsTypeDescrText = {
0 : "unknown type of drive"
, 1 : "drive with removable medium (e.g. Floppy)"
, 2 : "fixed drive (e.g. harddisk)"
, 3 : "remote (i.e. network) drive"
, 4 : "CD-ROM drive"
, 5 : "RAM-Disk drive"
}
lstdriveLetterOFonSYSTstorageDevice = []
lstdriveTypeOFonSYSTstorageDevice = []
for axDrive in axLstDrives:
if(axDrive.IsReady): # checks if a CD is inserted
lstdriveLetterOFonSYSTstorageDevice.append(
axDrive.DriveLetter.encode()
)
lstdriveTypeOFonSYSTstorageDevice.append(
dctAXaxFSO_NumCodeAsKeyVsTypeDescrText[axDrive.DriveType]
)
# axDrive.SerialNumber
# axDrive.VolumeName.encode()
# for more of this kind just check out e.g. in the by Microsoft
# free available JScript tutorial the chapter
# "FileSystemObject Sample Code"
#:if
#:for
Hope this helps.
Claudio
"Heiko Selber" <heiko.selber at siemens.com> schrieb im Newsbeitrag
news:d42lho$fbf$1 at news.mch.sbs.de...
> I am trying to find out (using Python under windows) the name of a CD that
> is currently in the drive specified by a path name.
>
> And while I am at it, I'd also like to know whether the specified drive
> contains a CD at all, and whether the drive is actually a CD drive.
>
> AFAIK, Python doesn't provide a way to do it, and a search in the web
> yielded only soutions for Linux.
>
> Can anyone show me a solution that works with windoze?
>
> TIA,
>
> Heiko
>
>
More information about the Python-list
mailing list