On the production of charmed mesons in high-energy proton-proton collisions