Jump to content

How to check the nature of your disk? (usb disk,cd drive,hdd,ssd ...)


Recommended Posts

hi, as part of my software, I need to understand the nature of the disks connected to the computer.

so i want get list of all connected disks to computer and find the nature of them and need to know disk's is:

1) flash disk ?

2) hard disk (internal or external) ?

3) cd drive (internal or external) ?

 

i test the command:

wmic logicaldisk get caption, description

and result is like this:

C:       Local Fixed Disk
D:       Removable Disk
E:       CD-ROM Disc
F:       Local Fixed Disk
G:       Local Fixed Disk

1) drive c is a internal hard drive (ssd)

2) drive d is a flash disk

3) drive e is a cd drive

4) drive f is 2 tb hard disk

5) drive g is 3 tb hard disk

 

i how can know witch drive is flash, hard disk (internal or external) and cd drive (internal or external) ?

thanks

Link to post
Share on other sites

Hi r2du-soft

For a start, you could try the function _WinAPI_GetDriveType
Here is the example found in AutoIt help file, a bit modified :

#include <WinAPIFiles.au3>

Example()

Func Example()
    Local $sDriveLetter, $iTypeOfDrive, $sMessage

    For $i = 65 To 90
        $sDriveLetter = Chr($i) & ":" ; "A:" to "Z:"
        $iTypeOfDrive = _WinAPI_GetDriveType($sDriveLetter)
        $sMessage = $sDriveLetter & " "

        Switch $iTypeOfDrive
            Case $DRIVE_UNKNOWN
                $sMessage &= "The drive type cannot be determined."
            Case $DRIVE_NO_ROOT_DIR
                $sMessage &= "The root path is invalid."
            Case $DRIVE_REMOVABLE
                $sMessage &= "The drive is a removable media."
            Case $DRIVE_FIXED
                $sMessage &= "The drive is a fixed drive."
            Case $DRIVE_REMOTE
                $sMessage &= "The drive is a remote (network) drive."
            Case $DRIVE_CDROM
                $sMessage &= "The drive is a CD-ROM drive."
            Case $DRIVE_RAMDISK
                $sMessage &= "The drive is a RAM disk."
        EndSwitch

        If $iTypeOfDrive <> $DRIVE_NO_ROOT_DIR Then ConsoleWrite($sMessage & @crlf)
    Next
EndFunc   ;==>Example
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...