Function Reference


_WinAPI_LockDevice

Enables or disables the mechanism that ejects media, for those devices possessing that locking capability

#include <WinAPIFiles.au3>
_WinAPI_LockDevice ( $sDrive, $bLock )

Parameters

$sDrive The drive letter of the device to enable or disable, in the format D:, E:, etc.
$bLock Specifies whether the device should be disabled, valid values:
    True - The device is disabled.
    False - The device is enabled.

Return Value

Success: True.
Failure: False and sets the @error flag to non-zero.

Remarks

This function is valid only for devices that support removable media.

See Also

Search IOCTL_STORAGE_MEDIA_REMOVAL in MSDN Library.

Example

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

Local $aDrive = DriveGetDrive('CDROM')

If IsArray($aDrive) Then
        _WinAPI_LockDevice($aDrive[1], 1)
        MsgBox($MB_SYSTEMMODAL, '', 'The drive (' & StringUpper($aDrive[1]) & ') is locked.')
        _WinAPI_LockDevice($aDrive[1], 0)
        MsgBox($MB_SYSTEMMODAL, '', 'The drive (' & StringUpper($aDrive[1]) & ') is unlocked.')
EndIf