Пример #1
0
 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);
     }
 }
Пример #2
0
 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;
 }
Пример #3
0
 public RemovableDrive()
 {
   NotWnd = new DeviceChangeNotificationWindow();
   NotWnd.DeviceChange += new DeviceChangeEventHandler(NotWnd_DeviceChange);
 }
 public RemovableDrive()
 {
     NotWnd = new DeviceChangeNotificationWindow();
     NotWnd.DeviceChange += new DeviceChangeEventHandler(NotWnd_DeviceChange);
 }
Пример #5
0
 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;
 }
Пример #6
0
 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;
   }
 }