Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 235161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:14:36+00:00 2026-05-11T20:14:36+00:00

I have tried this code: uses MMSystem; mciSendString(‘Set cdaudio door open wait’, nil, 0,

  • 0

I have tried this code:

uses MMSystem;

mciSendString('Set cdaudio door open wait', nil, 0, handle);

mciSendString('Set cdaudio door closed wait', nil, 0, handle);

but there was no effect. I have heard that this does not work on all systems.

I’m trying to get a drive to eject on Windows XP, and would like to specify the drive via the drive letter (necessary for systems with multiple drives).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T20:14:37+00:00Added an answer on May 11, 2026 at 8:14 pm

    This is code using the DeviceIOControl() API function, works for me on Windows XP (compiled and tested using Delphi 5):

    function DeviceIOControlHelper(ADeviceHandle: THandle;
      ADeviceIOControlCode: DWORD): boolean;
    var
      BytesReturned: Cardinal;
    begin
      Result := DeviceIOControl(ADeviceHandle, ADeviceIOControlCode,
        nil, 0, nil, 0, BytesReturned, nil);
    end;
    
    function SetDriveDoorOpen(ADriveLetter: char; AValue: boolean): boolean;
    const
      FILE_DEVICE_FILE_SYSTEM = 9;
      FILE_ANY_ACCESS = 0;
      FILE_READ_ACCESS = 1;
      METHOD_BUFFERED = 0;
      IOCTL_STORAGE_BASE = $2D;
    
    (*
    #define CTL_CODE( DeviceType, Function, Method, Access ) (                 \
        ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) \
    *)
    
    //  FSCTL_LOCK_VOLUME = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 6,
    //                               METHOD_BUFFERED, FILE_ANY_ACCESS);
      FSCTL_LOCK_VOLUME = (FILE_DEVICE_FILE_SYSTEM shl 16)
                          or (FILE_ANY_ACCESS shl 14)
                          or (6 shl 2) or METHOD_BUFFERED;
    //  FSCTL_DISMOUNT_VOLUME = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 8,
    //                                   METHOD_BUFFERED, FILE_ANY_ACCESS);
      FSCTL_DISMOUNT_VOLUME = (FILE_DEVICE_FILE_SYSTEM shl 16)
                              or (FILE_ANY_ACCESS shl 14)
                              or (8 shl 2) or METHOD_BUFFERED;
    //  IOCTL_STORAGE_EJECT_MEDIA = CTL_CODE(IOCTL_STORAGE_BASE, 0x0202,
    //                                       METHOD_BUFFERED, FILE_READ_ACCESS);
      IOCTL_STORAGE_EJECT_MEDIA = (IOCTL_STORAGE_BASE shl 16)
                                  or (FILE_READ_ACCESS shl 14)
                                  or ($0202 shl 2) or METHOD_BUFFERED;
    //  IOCTL_STORAGE_LOAD_MEDIA = CTL_CODE(IOCTL_STORAGE_BASE, 0x0203,
    //                                      METHOD_BUFFERED, FILE_READ_ACCESS);
      IOCTL_STORAGE_LOAD_MEDIA = (IOCTL_STORAGE_BASE shl 16)
                                  or (FILE_READ_ACCESS shl 14)
                                  or ($0203 shl 2) or METHOD_BUFFERED;
    var
      DriveCmdStr: string;
      DriveHandle: THandle;
    begin
      Result := FALSE;
      DriveCmdStr := Format('\\.\%s:', [ADriveLetter]);
      DriveHandle := CreateFile(PChar(DriveCmdStr), GENERIC_READ, FILE_SHARE_WRITE,
        nil, OPEN_EXISTING, 0, 0);
      if DriveHandle <> INVALID_HANDLE_VALUE then begin
        if AValue then begin
          Result := DeviceIOControlHelper(DriveHandle, FSCTL_LOCK_VOLUME)
            and DeviceIOControlHelper(DriveHandle, FSCTL_DISMOUNT_VOLUME)
            and DeviceIOControlHelper(DriveHandle, IOCTL_STORAGE_EJECT_MEDIA);
        end else
          Result := DeviceIOControlHelper(DriveHandle, IOCTL_STORAGE_LOAD_MEDIA);
        CloseHandle(DriveHandle);
      end;
    end;
    

    Error handling omitted.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 108k
  • Answers 108k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I would use and in your code behind, load up… May 11, 2026 at 9:17 pm
  • Editorial Team
    Editorial Team added an answer I don't think you're breaking any rule, but sys.stdout =… May 11, 2026 at 9:17 pm
  • Editorial Team
    Editorial Team added an answer Check out the /desktopmodules/AuthenticationServices directory. The out-of-the-box login control should… May 11, 2026 at 9:17 pm

Related Questions

I have some code in C# which has a com wrapper. This com wrapper
I am wrapping existing C++ code from a BSD project in our own custom
I am working on code (legacy code) which uses Apache Xerces-C library. I am
For some reason neither the accepted answer nor any others work for me for
I have a Java Applet that uses AWT. In some (rare) circumstances, the platform

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.