For Visual Studio 2005:
If you do have an installed Visual Studio 2005 however, and want to find out the serial number you’ve used to install it because you don’t have a clue where you put that shiny sticker, you can. It is, like most things in Windows, in the registry.
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\Registration\PIDKEY
In order to convert the value in that key to an actual serial number you have to put a dash ( – ) after evert 5 characters of the code.
From: http://www.gooli.org/blog/visual-studio-2005-serial-number/
For Visual Studio 2008 it's supposed to be:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\Registration\PIDKEY
However I noted that the the Data field for PIDKEY is only filled in the 1000.0x000
(or 2000.0x000) sub folder of the above paths.