An optical disk drive includes a main body and a tray. A tray locking
mechanism includes a base fixed to the tray, a locking device installed
on the base for combining with or separating from a stop pin of the main
body, a transmission device installed on the base for driving the locking
device, and a control device installed on the base for stopping the
transmission device. When the locking device combines with the stop pin
of the main body, the tray can be locked to the main body, and when the
transmission device drives the locking device to be separated from the
stop pin of the main body, the tray can eject from the main body and the
control device can stop the transmission device from rotating.