Windows 10: Ejecting Removable Disk

Discus and support Ejecting Removable Disk in Windows 10 Software and Apps to solve the problem; I'm writing a C program for Windows that deals specifically with lettered optical drives. From the dearth of information, I gather no easy solution... Discussion in 'Windows 10 Software and Apps' started by rLsj, Mar 14, 2018.

  1. rLsj Win User

    Ejecting Removable Disk


    I'm writing a C program for Windows that deals specifically with lettered optical drives. From the dearth of information, I gather no easy solution exists for programmatically ejecting such a disk. But I'll ask. Does anyone know an API under C that can be used to eject an optical disk without disturbing the user, such as a disk mounted on drive e:?

    Thank you for your attention.

    --

    :)
     
  2. Kris.ZB Win User

    Xbox one. Disk is stuck

    Alright, I have tried to do the restart option, I have tried to use the little hole by the reconnect button but the disk is stuck. Any tips on how to remove the disk with out having to send it in? It still makes the eject noise like how the disk is normally
    ejected.
     
    Kris.ZB, Mar 14, 2018
    #2
  3. problem show local disk on my computer from last localdisk connect and dont remove

    when i connect my hdd external i must go to disk management and click change my drive letter and add drive letter and then my laptop open my hdd external. and after remove and eject my hard external still that local disk in my laptop show and don't clean
    from my this pc.

    when I click on this local disk I see error "location is not availabale" and I don't know how can remove this local disk from this pc after eject my h.d.d external.

    I convert my laptop h.d.d to external h.d.d and there are two drive in my external h.d.d
     
    حمیدصلواتی, Mar 14, 2018
    #3
  4. Bree New Member

    Ejecting Removable Disk

    Does this help?

    https://support.microsoft.com/en-us/...000-windows-xp
     
  5. rLsj Win User
    Thank you very much!

    My program deals solely with read-only optical disks -- no flashdrive, so I believe that a drastic shortening of your example will work. Here is the resulting code. It compiles cleanly but I'm not yet far along enough to test it. Will report later.

    --

    Code: #include <windows.h> #include <winioctl.h> #include <tchar.h> #include <stdio.h> /* Eject optical disk */ void eject(drn) char *drn; /* drive ID letter (& Ejecting Removable Disk :) */ { HANDLE hvol; DWORD byr; /* entry */ hvol = CreateFile(drn,GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,0,OPEN_EXISTING,0,0); if (hvol == INVALID_HANDLE_VALUE) { printf("Manually eject %s\n",drn); return; } DeviceIoControl(hvol,IOCTL_STORAGE_EJECT_MEDIA,0,0,0,0,&byr,0); CloseHandle(hvol); return; }[/quote]
     
  6. Bree New Member
    Glad to hear that, but I can't take credit for the example (that goes to Microsoft) just for knowing where to look for one *Smile
     
  7. rLsj Win User
    Well, it didn't work. Amended the code to show the system reason. When "drn" contains, "e:", the actual optical drive ID, the system message is "Access denied." With anything else it reports can't find the file or the path. To "\\e:" it reported couldn't find the network drive. "e:" worked with an earlier call to GetVolumeInformation, so I conclude that must be the expected name format.

    "Access denied" smacks of administrative privilege. So I ran the program under Task Manager, giving it administrative privilege. Same result: "Access denied."

    Guess when running this program I'll have to keep a File Manager window open to click "eject." Sigh.

    Code: #include <windows.h> #include <winioctl.h> #include <tchar.h> #include <stdio.h> /* Eject optical disk */ void eject(drn) char *drn; /* drive ID letter (& Ejecting Removable Disk :) */ { HANDLE hvol; int dwfl; DWORD byr; char msbuf[256]; /* entry */ hvol = CreateFile(drn,GENERIC_READ, 0,0,OPEN_EXISTING,0,0); if (hvol == INVALID_HANDLE_VALUE) { byr = GetLastError(); FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,0,byr, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),msbuf,256,0); puts(msbuf); printf("Manually eject %s\n",drn); return; } DeviceIoControl(hvol,IOCTL_STORAGE_EJECT_MEDIA,0,0,0,0,&byr,0); CloseHandle(hvol); return; }[/quote]
     
  8. Berton Win User

    Ejecting Removable Disk

    What kind of computer, Desktop or Notebook? Some Desktop keyboards or third-party keyboards have an Eject key for ODDs as do a number of Notebooks, especially those marked for multi-media use. If playing audio CDs in Windows Media Player there is an Eject choice on one of the Menu items [Ctrl+J], other such programs may have it. Don't find it on VLC.
     
    Berton, Mar 16, 2018
    #8
  9. Bree New Member
    There's an eject button in VLC's 'Media > Open disc...' - use Ctrl+D for that.

    @rLsj, if you like, you could find out how theirs works by searching through VLC's source code, available here.
    VLC media player source code - VideoLAN

    Being Open Source and covered by the GPL you're free to use their code.
     
  10. What sets you apart is: You know where to look and what to look for! *Thumbs
     
    Wiley Coyote, Apr 5, 2018
    #10
Thema:

Ejecting Removable Disk

Loading...
  1. Ejecting Removable Disk - Similar Threads - Ejecting Removable Disk

  2. Eject disk 2.0

    in Windows 10 Gaming
    Eject disk 2.0: I just bought a 32GB SanDisk ultra Luxe USB 3.1 Flash Drive. It's written on the pack USB 3.1 Gen 1. When I tried pulling files to the drive, the speed is not a fast as I wanted. Also, when I tried ejecting the drive, I saw eject disk 2.0 and I don't understand. Any reason to...
  3. Eject disk 2.0

    in Windows 10 Software and Apps
    Eject disk 2.0: I just bought a 32GB SanDisk ultra Luxe USB 3.1 Flash Drive. It's written on the pack USB 3.1 Gen 1. When I tried pulling files to the drive, the speed is not a fast as I wanted. Also, when I tried ejecting the drive, I saw eject disk 2.0 and I don't understand. Any reason to...
  4. Eject disk 2.0

    in Windows 10 Drivers and Hardware
    Eject disk 2.0: I just bought a 32GB SanDisk ultra Luxe USB 3.1 Flash Drive. It's written on the pack USB 3.1 Gen 1. When I tried pulling files to the drive, the speed is not a fast as I wanted. Also, when I tried ejecting the drive, I saw eject disk 2.0 and I don't understand. Any reason to...
  5. "Cannot eject disk" error

    in Windows 10 Network and Sharing
    "Cannot eject disk" error: Long story short. I connected a external harddrive with its own power source, because it's a large 3.5 inch drive to my computer or laptop's USB port. I copied some files and now I want to eject it, but Windows says "problem ejecting USB drive" and claiming that "the device...
  6. Problem ejecting hard disk

    in Windows 10 BSOD Crashes and Debugging
    Problem ejecting hard disk: Hi I have been using my laptop for 2 years now And I have an external hard disk I was even using that for a while now on my computer But recently when I plugged in my hard disk and after using it when I clicked on eject This message poped up The...
  7. Problem ejecting hard disk

    in AntiVirus, Firewalls and System Security
    Problem ejecting hard disk: Hi I have been using my laptop for 2 years now And I have an external hard disk I was even using that for a while now on my computer But recently when I plugged in my hard disk and after using it when I clicked on eject This message poped up The...
  8. Disk keeps ejecting and appearing?

    in Windows 10 Ask Insider
    Disk keeps ejecting and appearing?: I am trying to install a game on my computer and it keeps ejecting and then appearing. submitted by /u/fridaysisterpeeplega [link] [comments] https://www.reddit.com/r/Windows10/comments/f423ay/disk_keeps_ejecting_and_appearing/
  9. An error occurred while ejecting 'Removeable Disk E'

    in Windows 10 Drivers and Hardware
    An error occurred while ejecting 'Removeable Disk E': I have an HP Pavilion dv7 and my optical disk DVD drive will no longer eject when I select the 'eject' function from the pop-up menu. When I select 'eject', I get the error message listed in the subject line. I've uninstalled the IDE ATA/ATAPI controllers and the DVD device...
  10. remove hardware and eject media

    in Windows 10 Drivers and Hardware
    remove hardware and eject media: Hi, I wanna solve this issue. I found out that this button shouldn't show unless I connect a external drive such as flash drive. It persists a long time now. It doesn't disappear. What should I do? Thank you. [ATTACH]...