Page 1 of 1
simple cd/dvd eject/load in win32 (2000/xp/vista/server2003)
Posted: Wed Sep 19, 2007 2:02 pm
by bingo
Code: Select all
#IOCTL_STORAGE_EJECT_MEDIA = $D4808
#IOCTL_STORAGE_LOAD_MEDIA = $2D480C
hDevice = CreateFile_("\\.\Cdrom0",#GENERIC_READ,#FILE_SHARE_READ,0,#OPEN_EXISTING,0,0)
If hDevice <> #INVALID_HANDLE_VALUE
DeviceIoControl_(hDevice,#IOCTL_STORAGE_EJECT_MEDIA,0,0,0,0,@bytesReturned,0)
Debug @bytesReturned
Delay(5000)
DeviceIoControl_(hDevice,#IOCTL_STORAGE_LOAD_MEDIA,0,0,0,0,@bytesReturned,0)
Debug @bytesReturned
CloseHandle_(hDevice)
EndIf
\\.\Cdrom0 the physical first cd/dvd
\\.\Cdrom1 the physical second cd/dvd
...
Posted: Thu Jan 22, 2009 9:19 pm
by Le Soldat Inconnu
Nice
It's work too with drive letter
example :
Code: Select all
#IOCTL_STORAGE_EJECT_MEDIA = $D4808
#IOCTL_STORAGE_LOAD_MEDIA = $2D480C
hDevice = CreateFile_("\\.\F:",#GENERIC_READ,#FILE_SHARE_READ,0,#OPEN_EXISTING,0,0)
If hDevice <> #INVALID_HANDLE_VALUE
DeviceIoControl_(hDevice,#IOCTL_STORAGE_EJECT_MEDIA,0,0,0,0,@bytesReturned,0)
Debug @bytesReturned
Delay(3000)
DeviceIoControl_(hDevice,#IOCTL_STORAGE_LOAD_MEDIA,0,0,0,0,@bytesReturned,0)
Debug @bytesReturned
CloseHandle_(hDevice)
EndIf
Re: simple cd/dvd eject/load in win32 (2000/xp/vista/server2
Posted: Fri Jun 28, 2013 12:14 pm
by sartic
not working here (win7 32bit)
another solution?
Re: simple cd/dvd eject/load in win32 (2000/xp/vista/server2
Posted: Sun Apr 06, 2014 11:21 pm
by tola
Hello,
I know it's a old post but i see an error in constant values.
"#IOCTL_STORAGE_EJECT_MEDIA = $D4808" is bad ....
"#IOCTL_STORAGE_EJECT_MEDIA = $2D4808" is right and, after, it's work on 7...
good night...