Hard Drive replacement

The other night my computer got a virus on the hard drive that totally f'd the computer. I cannot open the C: drive which is hard drive disk, and when I tr to it says some .com directory cannot be located. Plus it wont me re-install XP, I lost sound, internet and the graphics are reverted back to Windows 98. So my question is if I replace the hard drive will I be able to restore the computer to factory settings or is it F'd beyond repair??