visual que net mejor entre diferencia desde descargar cual cero caracteristicas c# vb.net drive eject

c# - mejor - visual basic.net que es



Programativamente expulsando y retrayendo la unidad de CD en vb.net o c# (2)

¿Hay alguna manera de hacerlo? Sé que es posible expulsar / retraer de forma programada la unidad de CD DE ALGUNA manera, porque Roxio lo hace cuando me pide que inserte un disco.

Ya sea c # o vb.net es preferible, pero c y c ++ también están bien como último recurso.

Estoy casi seguro de que hay alguna forma de hacerlo, simplemente no sé los métodos para llamar.

Entiendo que esta es una solicitud algo inusual, ya que Google no produjo absolutamente nada cuando busqué los métodos ...


Aquí hay una solución alternativa a la aceptada, convertida de una muestra de VB.NET :

using System; using System.IO; using System.Runtime.InteropServices; class Test { const int OPEN_EXISTING = 3; const uint GENERIC_READ = 0x80000000; const uint GENERIC_WRITE = 0x40000000; const uint IOCTL_STORAGE_EJECT_MEDIA = 2967560; [DllImport("kernel32")] private static extern IntPtr CreateFile (string filename, uint desiredAccess, uint shareMode, IntPtr securityAttributes, int creationDisposition, int flagsAndAttributes, IntPtr templateFile); [DllImport("kernel32")] private static extern int DeviceIoControl (IntPtr deviceHandle, uint ioControlCode, IntPtr inBuffer, int inBufferSize, IntPtr outBuffer, int outBufferSize, ref int bytesReturned, IntPtr overlapped); [DllImport("kernel32")] private static extern int CloseHandle(IntPtr handle); static void EjectMedia(char driveLetter) { string path = "////.//" + driveLetter + ":"; IntPtr handle = CreateFile(path, GENERIC_READ | GENERIC_WRITE, 0, IntPtr.Zero, OPEN_EXISTING, 0, IntPtr.Zero); if ((long) handle == -1) { throw new IOException("Unable to open drive " + driveLetter); } int dummy = 0; DeviceIoControl(handle, IOCTL_STORAGE_EJECT_MEDIA, IntPtr.Zero, 0, IntPtr.Zero, 0, ref dummy, IntPtr.Zero); CloseHandle(handle); } static void Main() { EjectMedia(''f''); } }


using System.Runtime.InteropServices; [DllImport("winmm.dll")] static extern Int32 mciSendString(String command, StringBuilder buffer, Int32 bufferSize, IntPtr hwndCallback); // To open the door mciSendString("set CDAudio door open", null, 0, IntPtr.Zero); // To close the door mciSendString("set CDAudio door closed", null, 0, IntPtr.Zero);

http://www.geekpedia.com/tutorial174_Opening-and-closing-the-CD-tray-in-.NET.html