Modify

Opened 12 years ago

Closed 12 years ago

Last modified 12 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 12 years ago.

Download all attachments as: .zip

Change History (14)

by mLipok, 12 years ago

Attachment: _WinAPI_GetDriveType.au3 added

comment:1 by guinness, 12 years ago

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 by anonymous, 12 years ago

1

in reply to:  1 ; comment:3 by anonymous, 12 years ago

1

comment:4 by guinness, 12 years ago

Resolution: Completed
Status: newclosed

in reply to:  description ; comment:5 by anonymous, 12 years ago

1

in reply to:  3 ; comment:6 by anonymous, 12 years ago

1

in reply to:  2 ; comment:7 by anonymous, 12 years ago

1

in reply to:  5 comment:8 by anonymous, 12 years ago

1

in reply to:  4 ; comment:9 by anonymous, 12 years ago

1

in reply to:  6 comment:10 by anonymous, 12 years ago

1

in reply to:  9 comment:11 by anonymous, 12 years ago

1

in reply to:  7 ; comment:12 by anonymous, 12 years ago

1

in reply to:  12 comment:13 by anonymous, 12 years ago

1

Modify Ticket

Action
as closed The ticket will remain with no owner.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.