There’s a number of ways to accomplish this, but the best way is to use the NirCmd utility from the excellent Nirsoft. It does a lot more than just eject the cd-rom drive, so be sure to read the information on their site about all the capabilities.
Create a Shortcut to Eject the CD/DVD Drive
Anywhere in the desktop right click and select New and then shortcut.

Now the location box will open here you have write the full path of nircmd.exe which is downloaded and at the end write “cdrom open” command so write the following path:
“C:\path\to\nircmd.exe” cdrom open D:
Here the important thing is to place the quotes at exact position of the path which is executable and then after quotes write arguments.

Write the appropriate name to the shortcut like Eject CD or anyone of your choice. Now you can see the shortcut

You can change the position of the icon now double click on it and see it will Eject the drive immediately.
Create a Shortcut to Close the CD/DVD Drive
For this you just have to write the same instruction but instead of “cdrom open” just write “cdrom close”.
Assign a Hotkey to the Shortcut
Now you can see the shortcut, we can also set the hotkey for this shortcut. Right click on the icon and select properties, select shortcut tab and write the key.

When you will add the shortcut key then you need to restart the system for better performance of the key. You can change the position of the shortcut to another folder for example quick launch bar.
In the windows vista quick launch bar you can use built in hotkey if you add shortcut to it.
Assign an Icon to the Shortcut
Here you can change the icon of the shortcut. Always gave the meaningful icon to the shortcut like given below we have selected CD icon.

You can select the icon of your choice on the system.