public bool Open(char Drive) { Close(); if (Win32Functions.GetDriveType(Drive + ":\\") == Win32Functions.DriveTypes.DRIVE_CDROM) { cdHandle = Win32Functions.CreateFile("\\\\.\\" + Drive + ':', Win32Functions.GENERIC_READ, Win32Functions.FILE_SHARE_READ, IntPtr.Zero, Win32Functions.OPEN_EXISTING, 0, IntPtr.Zero); if (((int)cdHandle != -1) && ((int)cdHandle != 0)) { m_Drive = Drive; NotWnd = new DeviceChangeNotificationWindow(); NotWnd.DeviceChange += new DeviceChangeEventHandler(NotWnd_DeviceChange); return(true); } else { m_Drive = Drive; if (NotWnd == null) { NotWnd = new DeviceChangeNotificationWindow(); NotWnd.DeviceChange += new DeviceChangeEventHandler(NotWnd_DeviceChange); } return(true); } } else { return(false); } }
public void Close() { UnLockCD(); if (NotWnd != null) { NotWnd.DeviceChange -= new DeviceChangeEventHandler(NotWnd_DeviceChange); NotWnd.DestroyHandle(); NotWnd = null; } if (((int)cdHandle != -1) && ((int)cdHandle != 0)) { Win32Functions.CloseHandle(cdHandle); } cdHandle = IntPtr.Zero; m_Drive = '\0'; TocValid = false; }
public RemovableDrive() { NotWnd = new DeviceChangeNotificationWindow(); NotWnd.DeviceChange += new DeviceChangeEventHandler(NotWnd_DeviceChange); }
public bool Open(char Drive) { Close(); if (Win32Functions.GetDriveType(Drive + ":\\") == Win32Functions.DriveTypes.DRIVE_CDROM) { cdHandle = Win32Functions.CreateFile("\\\\.\\" + Drive + ':', Win32Functions.GENERIC_READ, Win32Functions.FILE_SHARE_READ, IntPtr.Zero, Win32Functions.OPEN_EXISTING, 0, IntPtr.Zero); if (((int)cdHandle != -1) && ((int)cdHandle != 0)) { m_Drive = Drive; NotWnd = new DeviceChangeNotificationWindow(); NotWnd.DeviceChange += new DeviceChangeEventHandler(NotWnd_DeviceChange); return true; } else { m_Drive = Drive; if (NotWnd == null) { NotWnd = new DeviceChangeNotificationWindow(); NotWnd.DeviceChange += new DeviceChangeEventHandler(NotWnd_DeviceChange); } return true; } } else { return false; } }