Commit 80aa3da1 authored by Xavier Marchesini's avatar Xavier Marchesini

 * intf_eject.c : added ejection code for Win32. Please test it under
                  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
parent 0170377d
...@@ -326,12 +326,12 @@ void __fastcall TMainFrameDlg::ToolButtonEjectClick( TObject *Sender ) ...@@ -326,12 +326,12 @@ void __fastcall TMainFrameDlg::ToolButtonEjectClick( TObject *Sender )
} }
/* If there's a stream playing, we aren't allowed to eject ! */ /* If there's a stream playing, we aren't allowed to eject ! */
if( p_input_bank->pp_input[0] == NULL ) // if( p_input_bank->pp_input[0] == NULL )
{ // {
intf_WarnMsg( 4, "intf: ejecting %s", Device.c_str() ); intf_WarnMsg( 4, "intf: ejecting %s", Device.c_str() );
intf_Eject( Device.c_str() ); intf_Eject( Device.c_str() );
} // }
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
...@@ -686,7 +686,7 @@ void __fastcall TMainFrameDlg::ModeManage() ...@@ -686,7 +686,7 @@ void __fastcall TMainFrameDlg::ModeManage()
/* set control items */ /* set control items */
ToolButtonBack->Enabled = false; ToolButtonBack->Enabled = false;
ToolButtonStop->Enabled = true; ToolButtonStop->Enabled = true;
ToolButtonEject->Enabled = !b_control; ToolButtonEject->Enabled = b_control;
ToolButtonPause->Enabled = b_control; ToolButtonPause->Enabled = b_control;
ToolButtonSlow->Enabled = b_control; ToolButtonSlow->Enabled = b_control;
ToolButtonFast->Enabled = b_control; ToolButtonFast->Enabled = b_control;
......
...@@ -219,7 +219,7 @@ object MainFrameDlg: TMainFrameDlg ...@@ -219,7 +219,7 @@ object MainFrameDlg: TMainFrameDlg
Top = 2 Top = 2
Hint = 'Eject disc' Hint = 'Eject disc'
Caption = 'Eject' Caption = 'Eject'
Enabled = False Enabled = True
ImageIndex = 7 ImageIndex = 7
OnClick = ToolButtonEjectClick OnClick = ToolButtonEjectClick
end end
......
...@@ -2,11 +2,12 @@ ...@@ -2,11 +2,12 @@
* intf_eject.c: CD/DVD-ROM ejection handling functions * intf_eject.c: CD/DVD-ROM ejection handling functions
***************************************************************************** *****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN * 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 * Author: Julien Blache <jb@technologeek.org> for the Linux part
* with code taken from the Linux "eject" command * with code taken from the Linux "eject" command
* Jon Lech Johansen <jon-vl@nanocrew.net> for Darwin * 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 * 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 * it under the terms of the GNU General Public License as published by
...@@ -66,6 +67,32 @@ ...@@ -66,6 +67,32 @@
# include <scsi/scsi_ioctl.h> # include <scsi/scsi_ioctl.h>
#endif #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 * Local prototypes
*****************************************************************************/ *****************************************************************************/
...@@ -127,7 +154,69 @@ int intf_Eject( const char *psz_device ) ...@@ -127,7 +154,69 @@ int intf_Eject( const char *psz_device )
return 1; 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; int i_fd;
......
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
* netutils.c: various network functions * netutils.c: various network functions
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * 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> * Authors: Vincent Seguin <seguin@via.ecp.fr>
* Benoit Steiner <benny@via.ecp.fr> * Benoit Steiner <benny@via.ecp.fr>
* Henri Fallon <henri@videolan.org> * Henri Fallon <henri@videolan.org>
* Xavier Marchesini <xav@via.ecp.fr> * Xavier Marchesini <xav@alarue.net>
* Christophe Massiot <massiot@via.ecp.fr> * Christophe Massiot <massiot@via.ecp.fr>
* Samuel Hocevar <sam@via.ecp.fr> * Samuel Hocevar <sam@via.ecp.fr>
* *
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment