Opening a CD-ROM tray with PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Opening a CD-ROM tray with PHP

Post by evilmonkey »

Does anyone know how to do it? I thought it'd be pretty cool. I know in Linux, there's an eject command that can be executed through exec(). How about in Windows? This is just something cool, wondering how to do it for further reference.

Cheers!
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

well if you did it it owuld open the tray on the server because php is serverside and not client side in any manner......

but hey what does little old me know.... :)
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post by nigma »

dull1554 wrote:but hey what does little old me know.... :)
Pull yourself together man! You're supposed to be a master.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: Opening a CD-ROM tray with PHP

Post by Weirdan »

evilmonkey wrote:Does anyone know how to do it? I thought it'd be pretty cool. I know in Linux, there's an eject command that can be executed through exec(). How about in Windows? This is just something cool, wondering how to do it for further reference.
In windoze you can do virtually anything via com objects. PHP/Win does support COM, hence you can open cd tray of a windows server. Here's VBScript code:

Code: Select all

Const CDROM = 4
For Each d in CreateObject("Scripting.FileSystemObject").Drives
  If d.DriveType = CDROM Then
    Eject d.DriveLetter & ":"
  End If
Next

Sub Eject(CDROM)
  Dim ssfDrives
  ssfDrives = 17
  CreateObject("Shell.Application")_
    .Namespace(ssfDrives).ParseName(CDROM).InvokeVerb("E&ject")
End Sub
Translating it into PHP code should be fairly simple and straightforward.
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Post by evilmonkey »

dull1554 wrote:well if you did it it owuld open the tray on the server because php is serverside and not client side in any manner......

but hey what does little old me know.... :)
Yes, but nowdays you can make PHP-GTK applications that run on Windows. ;)

Wierdan, thanks for the hint. :)
Shendemiar
Forum Contributor
Posts: 404
Joined: Thu Jan 08, 2004 8:28 am

Post by Shendemiar »

nigma wrote:
dull1554 wrote:but hey what does little old me know.... :)
Pull yourself together man! You're supposed to be a master.

Lol :D
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post by nigma »

:roll: Well, it's true.
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

i wish i could give myself my own rank, it would be "COMPLETE MORON"

but hey......

im just gonna stop now

....and evilmonkey im gonna have to look into that PHP-GTK stuff sounds like it could have potential
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

nah, we like wxPython more ;)
Post Reply