Declare Function DeviceIoControl Lib "kernel32" ( _
ByVal hDevice As Long, _
ByVal dwIoControlCode As Long, _
lpInBuffer As Any, _
ByVal nInBufferSize As Long, _
lpOutBuffer As Any, _
ByVal nOutBufferSize As Long, _
lpBytesReturned As Long, _
lpOverlapped As Any) As Long
DeviceIoControl выполняет заданную операцию с устройством, используя его драйвер напрямую.
' выдвигаем лоток DVD-ROM (только под Win 2000/XP) Dim hDrive As Long, DummyReturnedBytes As Long Dim EjectDrive As String, DriveLetterAndColon As String EjectDrive = InputBox("Введите букву вашего DVD-ROM для извлечения лотка") If Len(EjectDrive) Then DriveLetterAndColon = UCase(Left$(EjectDrive & ":", 2)) hDrive = CreateFile("\\.\" & DriveLetterAndColon, GENERIC_READ Or GENERIC_WRITE, 0, ByVal 0, OPEN_EXISTING, 0, 0) If hDrive <> INVALID_HANDLE_VALUE Then ' выдвигаем лоток Call DeviceIoControl(hDrive, IOCTL_STORAGE_EJECT_MEDIA, 0, 0, 0, 0, DummyReturnedBytes, ByVal 0) Call CloseHandle(hDrive) End If End If