First, you should know that there are no guarantees. I've yet to find a technique that always gets every file needed by every driver. But I can recommend two approaches, either of which will get the vast majority and quite likely all of them. As an extra precaution, you might use both.
The first is driverback.bat, a batch file I wrote when I last answered this question in 2005 (if that link brings you to a web page of text rather than a file download dialog box, copy and paste that text into Notepad and save it as driverback.bat). This makes for an extremely easy backup and a reasonably easy restore, although it backs up far more files than you're likely to need. Another problem: It doesn't work in Vista--one more reason why I'm giving an alternative solution.
Running my batch file copies a great many files to a folder inside My Documents called driverback. Copy this folder to an external drive or burn it to CD for safe keeping.
To restore your drivers to a fresh XP installation, connect or insert the media containing your driverback backup. Select Start, Run, type sysdm.cpl, and press ENTER. Click the Hardware tab, then the Device Manager button.
Repeat the following steps for each item listed that displays a yellow question mark:
1. Right-click the item and select Update Driver.
2. In the resulting Hardware Update Wizard, select Install from a list or specific location (Advanced) and click Next.
3. Check Include this location in the search and point it to your driverback folder. Click Next.
4. If the installation pauses because it can't find a file, point it to your driverback folder.
If you're using Vista, don't trust my admittedly crude batch file, or just want two backups, consider Innovative Solution's free DriverMax (http://www.innovative-sol.com/drivermax/). (Free, yes, but you still must register it if you wish to keep using it.)
Once installed and registered, it backs up and restores drivers with almost no fuss.