Modify

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#2762 closed Feature Request (Completed)

Example proposal - _WinAPI_GetDriveType.au3

Reported by: mLipok Owned by:
Milestone: Component: Documentation
Version: Severity: None
Keywords: Cc:

Description

Source:

http://www.autoitscript.com/forum/topic/162237-the-bumper-thread-of-missing-winapi-examples/#entry1178979

#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
#include <APIFilesConstants.au3>

Example_WinAPI_GetDriveType()

Func Example_WinAPI_GetDriveType()

    Local $iTypeOfDrive = _WinAPI_GetDriveType("C:")
    If $iTypeOfDrive = $DRIVE_UNKNOWN Or $iTypeOfDrive = $DRIVE_NO_ROOT_DIR Then
        MsgBox($MB_SYSTEMMODAL, "Failure", "The path is invalid or the type cannot be determined")
    EndIf

    Switch $iTypeOfDrive
        ; Case $DRIVE_UNKNOWN
        ;    ConsoleWrite("The drive type cannot be determined." & @LF)
        ; Case $DRIVE_NO_ROOT_DIR
        ;    ConsoleWrite("The root path is invalid; for example, there is no volume mounted at the specified path." & @LF)
        Case $DRIVE_REMOVABLE
            ConsoleWrite("The drive has removable media; for example, a floppy drive, thumb drive, or flash card reader." & @LF)
        Case $DRIVE_FIXED
            ConsoleWrite("The drive has fixed media; for example, a hard disk drive or flash drive." & @LF)
        Case $DRIVE_REMOTE
            ConsoleWrite("The drive is a remote (network) drive." & @LF)
        Case $DRIVE_CDROM
            ConsoleWrite("The drive is a CD-ROM drive." & @LF)
        Case $DRIVE_RAMDISK
            ConsoleWrite("The drive is a RAM disk." & @LF)
    EndSwitch

    Return $iTypeOfDrive
EndFunc   ;==>Example_WinAPI_GetDriveType

Attachments (1)

_WinAPI_GetDriveType.au3 (1.3 KB) - added by mLipok 6 years ago.

Download all attachments as: .zip

Change History (14)

Changed 6 years ago by mLipok

comment:1 follow-up: Changed 6 years ago by guinness

ConsoleWrite() shouldn't be used in the examples as not everyone is using SciTE or something that captures the standard input output stream. You also have a message box to display an error but then proceed to display the consolewrite lines regardless.

comment:2 follow-up: Changed 6 years ago by anonymous

1

comment:3 in reply to: ↑ 1 ; follow-up: Changed 6 years ago by anonymous

1

comment:4 follow-up: Changed 6 years ago by guinness

  • Resolution set to Completed
  • Status changed from new to closed

comment:5 in reply to: ↑ description ; follow-up: Changed 6 years ago by anonymous

1

comment:6 in reply to: ↑ 3 ; follow-up: Changed 6 years ago by anonymous

1

comment:7 in reply to: ↑ 2 ; follow-up: Changed 6 years ago by anonymous

1

comment:8 in reply to: ↑ 5 Changed 6 years ago by anonymous

1

comment:9 in reply to: ↑ 4 ; follow-up: Changed 6 years ago by anonymous

1

comment:10 in reply to: ↑ 6 Changed 6 years ago by anonymous

1

comment:11 in reply to: ↑ 9 Changed 6 years ago by anonymous

1

comment:12 in reply to: ↑ 7 ; follow-up: Changed 6 years ago by anonymous

1

comment:13 in reply to: ↑ 12 Changed 6 years ago by anonymous

1

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The ticket will remain with no owner.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.