Although not easy to do, the best thing is to have the car inspected BEFORE you buy it. It is sort of a pain to coordinate, but you need to get the car on a lift and look for accident damage and over spray, as was mentioned. It is best to drive it, but usually a test drive around the block won't tell you everything. Trying to find a competent person to inspect it is rare as well.
All you can do is do the most that you can. Autocheck, Carfax, see the car, drive the car, have the car inspected... all this costs money and could end in nothing.
I tried to have my car inspected at the best place, but it was too far for the owner, so I went to a local Dodge dealer who may or may not have known what they were doing. At least I saw the car myself on the lift and did the best I could.
No matter what you do, you never really feel 100% until time passes. I eventually took the car that I already purchased to Tator's Garage, the wizard, and once he gave the car his blessing - THEN I felt 100%. If something was wrong, too late.