]> git.sesse.net Git - vlc/commitdiff
* intf_eject.c : added ejection code for Win32. Please test it under
authorXavier Marchesini <xav@videolan.org>
Thu, 30 May 2002 08:59:42 +0000 (08:59 +0000)
committerXavier Marchesini <xav@videolan.org>
Thu, 30 May 2002 08:59:42 +0000 (08:59 +0000)
                  Win95/98/Me, I just can't install a winme
                  in my work office :).
 * plugins/win32/* : enabled the "Eject" button (thanks Ipkiss)
 * src/misc/netutils.c : just changed my mail :P

plugins/win32/mainframe.cpp
plugins/win32/mainframe.dfm
src/interface/intf_eject.c
src/misc/netutils.c

index 76eac03207d2330e0f9a4b2645dc761627b28df1..582b94b8b2638cfa7b45222936a8474cd64fcf1e 100644 (file)
@@ -326,12 +326,12 @@ void __fastcall TMainFrameDlg::ToolButtonEjectClick( TObject *Sender )
     }\r
 \r
     /* If there's a stream playing, we aren't allowed to eject ! */\r
-    if( p_input_bank->pp_input[0] == NULL )\r
-    {\r
+//    if( p_input_bank->pp_input[0] == NULL )\r
+//    {\r
         intf_WarnMsg( 4, "intf: ejecting %s", Device.c_str() );\r
 \r
         intf_Eject( Device.c_str() );\r
-    }\r
+//    }\r
 }\r
 //--------------------------------------------------------------------------\r
 \r
@@ -686,7 +686,7 @@ void __fastcall TMainFrameDlg::ModeManage()
     /* set control items */\r
     ToolButtonBack->Enabled = false;\r
     ToolButtonStop->Enabled = true;\r
-    ToolButtonEject->Enabled = !b_control;\r
+    ToolButtonEject->Enabled = b_control;\r
     ToolButtonPause->Enabled = b_control;\r
     ToolButtonSlow->Enabled = b_control;\r
     ToolButtonFast->Enabled = b_control;\r
index c7736c7bfefd82c1704eed09baafff24f288b781..7ccf8d7956350d47b99368e8f16dde47a83b5243 100644 (file)
@@ -219,7 +219,7 @@ object MainFrameDlg: TMainFrameDlg
       Top = 2\r
       Hint = 'Eject disc'\r
       Caption = 'Eject'\r
-      Enabled = False\r
+      Enabled = True\r
       ImageIndex = 7\r
       OnClick = ToolButtonEjectClick\r
     end\r
index d286ea6880c3c52ba2ae8370c7451db38d574038..862cefca6a4d806eb87fcbd03b99e3b723828c2e 100644 (file)
@@ -2,11 +2,12 @@
  * intf_eject.c: CD/DVD-ROM ejection handling functions
  *****************************************************************************
  * Copyright (C) 2001, 2002 VideoLAN
- * $Id: intf_eject.c,v 1.11 2002/05/06 23:18:26 jlj Exp $
+ * $Id: intf_eject.c,v 1.12 2002/05/30 08:59:42 xav Exp $
  *
  * Author: Julien Blache <jb@technologeek.org> for the Linux part
  *               with code taken from the Linux "eject" command
  *         Jon Lech Johansen <jon-vl@nanocrew.net> for Darwin
+ *         Xavier Marchesini <xav@alarue.net> for Win32
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
 #   include <scsi/scsi_ioctl.h>
 #endif
 
+#ifdef WIN32 
+#   include <windows.h>
+#   include <stdio.h>
+#   include <winioctl.h>
+#   include <ctype.h>
+#   include <tchar.h>
+
+/* define the structures to eject under Win95/98/Me */
+
+#if !defined (VWIN32_DIOC_DOS_IOCTL)
+#define VWIN32_DIOC_DOS_IOCTL      1
+
+typedef struct _DIOC_REGISTERS {
+    DWORD reg_EBX;
+    DWORD reg_EDX;
+    DWORD reg_ECX;
+    DWORD reg_EAX;
+    DWORD reg_EDI;
+    DWORD reg_ESI;
+    DWORD reg_Flags;
+} DIOC_REGISTERS, *PDIOC_REGISTERS;
+#endif    /* VWIN32_DIOC_DOS_IOCTL */
+
+#endif
+
+
 /*****************************************************************************
  * Local prototypes
  *****************************************************************************/
@@ -127,8 +154,70 @@ int intf_Eject( const char *psz_device )
 
     return 1;
 
-#else /* SYS_DARWIN */
+#elif defined(WIN32) 
+    
+    HANDLE h_drive ;
+    TCHAR  psz_drive_id[8] ;
+    DWORD  dw_access_flags = GENERIC_READ ;
+    DWORD  dw_result ;
+    LPTSTR psz_volume_format = TEXT("\\\\.\\%s") ;
+    BYTE   by_drive ;
+    DIOC_REGISTERS regs = {0} ;
+    
+    /* Win2K ejection code */
+    if ( GetVersion() < 0x80000000 )
+    {
+        intf_WarnMsg (3, "intf: win2k ejecting procedure launched") ;
+        
+        wsprintf(psz_drive_id, psz_volume_format, psz_device) ;
+         
+        intf_WarnMsg(3, "intf: Ejecting drive %s", psz_drive_id) ;
+        
+        /* Create the file handle */ 
+        h_drive = CreateFile(  psz_drive_id, 
+                               dw_access_flags, 
+                               FILE_SHARE_READ | FILE_SHARE_WRITE,
+                               NULL,
+                               OPEN_EXISTING,
+                               0,
+                               NULL );
+
+        if (h_drive == INVALID_HANDLE_VALUE )
+        {
+            intf_ErrMsg ("intf error: (Win32) couldn't create handle for device %s", psz_device) ;
+        }
 
+        i_ret = DeviceIoControl ( h_drive, 
+                                 IOCTL_STORAGE_EJECT_MEDIA,
+                                 NULL, 0,
+                                 NULL, 0, 
+                                 &dw_result, 
+                                 NULL);
+        return (i_ret) ;
+    }
+    else        /* Win95/98/ME */
+    {
+        /* Create the handle to VWIN32 */
+        h_drive = CreateFile ("\\\\.\\vwin32", 0, 0, NULL, 0,
+                              FILE_FLAG_DELETE_ON_CLOSE, NULL ) ;
+        
+        /* Convert logical disk name to DOS-like disk name */
+        by_drive = (toupper (*psz_device) - 'A') + 1;
+
+        /* Let's eject now : Int 21H function 440DH minor code 49h*/
+        regs.reg_EAX = 0x440D ;                        
+        regs.reg_EBX = by_drive ;
+        regs.reg_ECX = MAKEWORD(0x49 , 0x08) ;        // minor code
+
+        i_ret = DeviceIoControl (h_drive, VWIN32_DIOC_DOS_IOCTL,
+                                 &regs, sizeof(regs), &regs, sizeof(regs),
+                                 &dw_result, 0) ;
+
+        CloseHandle (h_drive) ;
+       return (i_ret) ;
+    }
+#else   /* WIN32 */
+    
     int i_fd;
 
     /* This code could be extended to support CD/DVD-ROM chargers */
index 8330994fa19e8f210ff7ec808e43397e26baa496..317c6fa8d26c8773d014b8405b35ac11b139e689 100644 (file)
@@ -2,12 +2,12 @@
  * netutils.c: various network functions
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: netutils.c,v 1.64 2002/05/25 19:15:50 marcari Exp $
+ * $Id: netutils.c,v 1.65 2002/05/30 08:59:42 xav Exp $
  *
  * Authors: Vincent Seguin <seguin@via.ecp.fr>
  *          Benoit Steiner <benny@via.ecp.fr>
  *          Henri Fallon <henri@videolan.org>
- *          Xavier Marchesini <xav@via.ecp.fr>
+ *          Xavier Marchesini <xav@alarue.net>
  *          Christophe Massiot <massiot@via.ecp.fr>
  *          Samuel Hocevar <sam@via.ecp.fr>
  *