Actually there is an easier way. Naviagate to the folder called "My Documents"
Then go to Music. Then you see that iTunes folder? Copy that to a hard drive if you have one. Then, after you reinstall windows, or OS X or whatever, you can install iTunes, and just put that folder back in the Music folder, and it will open exactly like you left it.