Sorry, I do not think there is a way within the software to retrieve a serial number. If you registered it with Adobe, they may have a record of it. Contact Customer Service.
The best way by far to "retrieve" your serial number is to keep a physical record of all your software purchases. You just never know when you will need it.
Please launch CS4 Photoshop on your old machine click on help and deactivate the product.
You can download CS4 Photoshop using the below link.
I have sent you the serial number for your CS4 Photoshop extended in a private message.
Please reply if you need further help.
Thank you for posting on Adobe Forums.