the best stuff I've ever seen is Amsoil Metal Protector, it's a synthetic you spray on, it leaves a wax/plastic coating over the gun until next time you want to shoot it.
if I had to store a pistol long term, I'd drop it in a bucket of new lightweight oil, like 3-in-1 oil, then let it drain on a thick rag- then pack it in grease, and put it in a ziplock bag to protect it from moisture.