# Function Reference

# _WinAPI_IsWritable

Determines whether a disk is writable

#include <WinAPIFiles.au3>
_WinAPI_IsWritable ( $sDrive )

## Parameters

$sDrive | The drive letter of the disk to check, in the format D:, E:, etc.

## Return Value

Success: | True - The disk is writable. False - Otherwise.
Failure: | Sets the @error flag to non-zero, @extended is set to last system error code.

## Remarks

The last error code = 41 means that the device is not ready, no media mounted.

## See Also

Search IOCTL_DISK_IS_WRITABLE in MSDN Library.

## Example

    #include <WinAPIError.au3>
    #include <WinAPIFiles.au3>

    Local $aDrive = DriveGetDrive('ALL')

    If IsArray($aDrive) Then
        Local $sText
        For $i = 1 To $aDrive[0]
            If _WinAPI_IsWritable($aDrive[$i]) Then
                $sText = 'Writable'
            Else
                If @error Then
                    $sText = 'No media'
                    If @extended Then $sText &= ' ( @error=' & @error & ' LastError=' & _WinAPI_GetLastErrorMessage() & ')'
                Else
                    $sText = 'Not writable'
                EndIf
            EndIf
            ConsoleWrite(StringUpper($aDrive[$i]) & ' => ' & $sText & @CRLF)
        Next
    EndIf