XP
To install on "royalty free OEM" machines (HP, DELL, etc.) you can get the vendor's oembios files from the oembios repository, or backed up from the current installation.
You then need to use the SLP (system locked preinstallation) key that corresponds to the installation media's product ID. These used to be archived on the My Digital Life forums, but were taken down due to DMCA request. I'm not sure if the particular vendor key is required, or if those provided by Microsoft will work. If you still have the original installation from the OEM, you can extract the SLP key they used for installation from the registry using a tool like produkey.
(Most antivirus seems to complain about produkey, but I've never had issues with it.)
nLite can help you create the ISO and be very useful for testing in a VM, but it's quite a bit more difficult to test the SLP activation with the VM.
This question is a little similar to something I have answered before. In my experience, if you have a computer with a COA sticker on the bottom, you can activate that key for the version of Windows that it's for on that computer as many times as you want. If you don't have a Windows installation disc for that specific version of windows, you can search the internet for an ISO image and burn a copy if you have to perform a clean install.
I always try to get an ISO file from a Windows source such as This first. If that for some reason doesn't work you can always try sources other than Microsoft such as This. If you try this link, please make sure to watch carefully when you are downloading. I had to create a quick and free account, and also there is a box that you need to uncheck that ask to download with a manager.
Just please read and look at all comments about the site you are downloading from. As a last resort you can also try to search a torrent site for a non activated copy. Make sure that it is a legal copy of Windows and does not say ANYTHING about pre-activated or cracked copy or anything similar. You want a copy that you have to activate.
After you have your ISO image file you can use a program such as Free ISO Burner to burn the image file to a DVD. The image file should already be bootable so you shouldn't have to mess with boot settings.
After you create your installation disc, you can then install windows. Use the COA key on the sticker to activate windows. When the install is finished you may still have to go into the activation wizard and complete a phone activation. The instructions to activate can be found here.
After you have everything activated and it shows that it is a genuine copy, you can then go to install updates. These will take forever, but you need to update.
That is pretty much it. I do not condone using illegal Keygens or hacks to activate windows so please make sure you try a Microsoft source first and make sure that it's a copy that you have to activate. The key is what makes the copy of Windows legal or illegal. You always want to have a good, safe, and legal installation of Windows.
PS. I just tried the method with downloading the ISO from the second source and tested it, and it works. The only other thing to note is that if you are using Free ISO Burner, make sure to check finalize disc. See below.
Best Answer
I find it hilarious that others are actually suggesting things like "do a refresh, it's Windows 8", or "Just use a keyfinder.".
Read the question the OP posted. The drive is CRASHED. Worst case scenario, it cannot even be read by another machine directly connected to SATA.
"Hey don't worry, just use the recovery disks!" - What is this, 2003? Most vendors (if not ALL by now) just shove your "restore disk" onto a separate partition on the hard drive [which, oh yeah, is dead now].
So, you can't use keyfinders cause the drive is toast, can't use recovery media because we've moved onto this streamlined 'it's on your hard drive' era, and a refresh is completely out of the question cause we obviously can't boot into Windows.
THE ACTUAL SOLUTION:
Get your hands on some clean installation media. If an official vendor will not give it to you, torrent it. We merely need to get Windows installed onto the machine with the NEW drive you have. The BIOS will at least tell us which version of Windows 8 it is. (If not, assume non-pro for consumer, and pro for business).
Click "skip" when the installer asks for the installation key when prompted. On the next screen, you'll hit CTRL + SHIFT + F3 to get to the "I'm an Admin, let me set up this computer for first time use" mode.
Download RWeverything (this reads the key out of the BIOS on Win8 Machines -- see this thread on how to use it) http://rweverything.com/download/ Then, hit the start button and open up Windows Activation (not the Win8 tile app, there should be a different one that shoots you back to the desktop). It will have an "activate" button. Click it and let it fail activation the first time. Then, it will ask if you want to try with a new key.
Insert key you found with RWeverything. Activate. SUCCESS.