Determine the type of drive

Just starting out? Need help? Post your questions and find answers here.
User avatar
RichAlgeni
Addict
Addict
Posts: 935
Joined: Wed Sep 22, 2010 1:50 am
Location: Bradenton, FL

Determine the type of drive

Post by RichAlgeni »

Is there a way to determine the type of a disk drive on a system? Specifically, I'd like to know if a drive is removable, and a DVD or Blu-ray drive. I am writing a process to convert DVD files to mp4's.
User avatar
jacdelad
Addict
Addict
Posts: 2032
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: Determine the type of drive

Post by jacdelad »

Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
User avatar
RichAlgeni
Addict
Addict
Posts: 935
Joined: Wed Sep 22, 2010 1:50 am
Location: Bradenton, FL

Re: Determine the type of drive

Post by RichAlgeni »

Thank you!!!
User avatar
skywalk
Addict
Addict
Posts: 4242
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: Determine the type of drive

Post by skywalk »

Code: Select all

Procedure.i SL_IsLocalDrive(Drive$)
  Drive$ = UCase(Left(Drive$, 1))
  Protected.i nDrive = RealDriveType_(Asc(Drive$) - 65, 0)
  Select nDrive
  Case #DRIVE_NO_ROOT_DIR
    nDrive = 0
  Case #DRIVE_UNKNOWN
    ndrive = 0
  Case #DRIVE_REMOVABLE
    nDrive = 1
  Case #DRIVE_FIXED
    nDrive = 1
  Case #DRIVE_REMOTE
    nDrive = 0
  Case #DRIVE_CDROM
    nDrive = 0
  Case #DRIVE_RAMDISK
    nDrive = 0  ; Could be -1, if allowing RAM Drives
  EndSelect
  ProcedureReturn nDrive
EndProcedure
Debug SL_IsLocalDrive("P")

Procedure.s SL_GetLocalDrives()
  Protected.i i, ri
  Protected.i mask = GetLogicalDrives_()
  Protected.s d$, r$
  For i = 0 To 31
    If mask & (1 << i)
      d$ = Chr('A' + i) + ":\"
      ri = GetDriveType_(d$)
      If ri <> #DRIVE_CDROM And (ri = #DRIVE_FIXED Or ri = #DRIVE_REMOVABLE)
        r$ + d$ + #CMA$
      EndIf
    EndIf
  Next i
  ProcedureReturn RTrim(r$, #CMA$)
EndProcedure
Debug SL_GetLocalDrives()
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
RichAlgeni
Addict
Addict
Posts: 935
Joined: Wed Sep 22, 2010 1:50 am
Location: Bradenton, FL

Re: Determine the type of drive

Post by RichAlgeni »

So, I really didn't use the code for the disk type, as it really didn't make a difference to what I was trying to accomplish.

This is what I wrote, a process to convert and combine DVD video files, and make one mp4 file.

https://www.purebasic.fr/english/viewtopic.php?t=83429
Post Reply