I am looking for a way to tell whether or not a specific CD-ROM drive is opened or closed?

I am also wondering how I can lock the drive... (even if you press the eject button on the drive it wont open).

Andrew