If you tried everything else, but before you spring for a new optical drive, try this:
Taken from: http://www.aumha.org/regfiles.php
Click the link immediately below to download the zipped .REG file. Read the accompanying .TXT file. Copy file cdgone.reg to your hard drive. In Explorer right-click the file name and select Merge. OK the operation. Restart your PC.
"Restore Missing CD Drive. Win XP ONLY!
The popular CDGONE
patch. CD drives may vanish in Windows Explorer, Device Manager, etc. if a third-party CD-burning package has been uninstalled and Registry references for some code modules aren’t removed successfully. This patch and a reboot usually will restore the missing drives. Any third party package still required will then have to be re-installed. For more information on this and other possible causes, see the “Problems” section of Alex Nichol’s Burning CDs in Windows XP
[The link immediately above is a very well written technical article concerning how CDs are written. Everything stated about CDs also applies to DVDs, too.]