| 1 | #include <MsgBoxConstants.au3> |
|---|
| 2 | #include <WinAPIFiles.au3> |
|---|
| 3 | #include <APIFilesConstants.au3> |
|---|
| 4 | |
|---|
| 5 | Example_WinAPI_GetDriveType() |
|---|
| 6 | |
|---|
| 7 | Func Example_WinAPI_GetDriveType() |
|---|
| 8 | |
|---|
| 9 | Local $iTypeOfDrive = _WinAPI_GetDriveType("C:") |
|---|
| 10 | If $iTypeOfDrive = $DRIVE_UNKNOWN Or $iTypeOfDrive = $DRIVE_NO_ROOT_DIR Then |
|---|
| 11 | MsgBox($MB_SYSTEMMODAL, "Failure", "The path is invalid or the type cannot be determined") |
|---|
| 12 | EndIf |
|---|
| 13 | |
|---|
| 14 | Switch $iTypeOfDrive |
|---|
| 15 | ; Case $DRIVE_UNKNOWN |
|---|
| 16 | ; ConsoleWrite("The drive type cannot be determined." & @LF) |
|---|
| 17 | ; Case $DRIVE_NO_ROOT_DIR |
|---|
| 18 | ; ConsoleWrite("The root path is invalid; for example, there is no volume mounted at the specified path." & @LF) |
|---|
| 19 | Case $DRIVE_REMOVABLE |
|---|
| 20 | ConsoleWrite("The drive has removable media; for example, a floppy drive, thumb drive, or flash card reader." & @LF) |
|---|
| 21 | Case $DRIVE_FIXED |
|---|
| 22 | ConsoleWrite("The drive has fixed media; for example, a hard disk drive or flash drive." & @LF) |
|---|
| 23 | Case $DRIVE_REMOTE |
|---|
| 24 | ConsoleWrite("The drive is a remote (network) drive." & @LF) |
|---|
| 25 | Case $DRIVE_CDROM |
|---|
| 26 | ConsoleWrite("The drive is a CD-ROM drive." & @LF) |
|---|
| 27 | Case $DRIVE_RAMDISK |
|---|
| 28 | ConsoleWrite("The drive is a RAM disk." & @LF) |
|---|
| 29 | EndSwitch |
|---|
| 30 | |
|---|
| 31 | Return $iTypeOfDrive |
|---|
| 32 | EndFunc ;==>Example_WinAPI_GetDriveType |
|---|