The preheating of the intergalactic medium by structure collapse and ultraviolet background (UVB) is investigated in cosmological hydrodynamical simulations. When gravitational collapse is the sole heating mechanism, we find that (1) 60% and 45% of the IGM are heated up to S > 8 and 17 keV cm(2), respectively, at z = 0, but the fractions drop rapidly to a few percent at z = 2; (2) the entropy of the circumhalo gas S-cir is higher than the virial entropy for more than 75% of the halos with masses M < 10(11.5) M-circle dot since z = 2, but the fraction higher than the entropy, S-pr, required in the preventive model of galaxy formation is only 15%-20% for halos with M < 10(10.5) M-circle dot at z = 0, and decreases as redshift increases; (3) assuming a metallicity of Z <= 0.03 Z(circle dot), the fraction of halos whose circumhalo gas has a cooling time longer than the Hubble time t(cool,cir) > t(H) is merely 5%-10% at z less than or similar to 0.5, and even less at z >= 1 for halos with M < 10(10.5) M-circle dot; and (4) gas in the filaments undergoes the strongest preheating. Furthermore, we show that the UVB cannot enhance the fraction of the IGM with S > 17 keV cm(2), but can increase the fraction of low-mass halos (<10(10.5) M-circle dot) having S-cir > S-pr to similar to 70% at z = 0 and that having t(cool,cir) > t(H) to 15%-30% at z less than or similar to 0.5. Our results indicate that preheating due to gravitational collapse and UVB is inadequate to fulfill the needs of the preventative model, especially for halos with 10(10.5) M-circle dot < M< 10(11.5) M-circle dot. Nevertheless, these two mechanisms might cause large-scale galactic conformity.