  (abridged) We use a one-dimensional hydrodynamical code to investigate the
effects of preheating on gas accretion and cooling in cold dark matter halos.
In the absence of radiative cooling, preheating reduces the amount of gas that
can be accreted into a halo, and the accreted gas fraction is determined by the
ratio of the initial specific entropy of the gas to the virial entropy of the
halo. In the presence of radiative cooling, preheating affects the gas fraction
that can cool in two different ways. For small halos with masses <10^12Msun,
preheating suppresses gas accretion, but most of the accreted gas can cool. For
more massive halos, preheating not only reduces the amount of accreted gas, but
also reduces the cooling efficiency. For both small and massive halos, gas
cooling is delayed by preheating and in an inside-out fashion if the halo gas
is assumed to be a single-phase medium. However, cooling can occur over a wider
range of redshifts and radii, if we assume a multi-phase medium. As examples,
two specific preheating cases are investigated. In the first case, the
preheating entropy is assumed to be proportional to the virial entropy of the
halo, as expected from AGN feedback. Such preheating effectively suppresses
radiative cooling in halos with M>10^13Msun. We suggest that this may be the
reason why the stellar mass function of galaxies breaks sharply at the massive
end. Such preheating also helps create the hot diffused halos within which the
"radio mode" feedback of AGNs can act effectively. In the second case, we
assume the intergalactic medium is warm. Here the total amount of gas that can
cool in a halo scales with halo mass as ~M^2, as would be required to match the
observed stellar- and HI-mass functions in the current CDM model at the small
mass end.
