Our 3 1/2 month old has just learned how to make an ear-piercing screech, which appears to either mean "happy" or "tired and grumpy".
How can we dissuade her from making this noise, without "ignoring" her when she's upset?
I took a slightly different approach to the other answers.
I simply ignored the screeching, and exaggerated my reactions to everything else.
If he smiled, cooed, burped, or even simply made eye contact, I would put on a big smile and talk to him, tickle him, etc..
When he made loud, painful sounds, I made sure my expression didn't flicker, and I gave him absolutely no response.
I figured that rewarding positive behavior, and ignoring negative behavior rather than actively discouraging it, would be an effective means of communication at that age, since they are so focused on watching for responses and learning how to interact. It did seem to work, as the loud screeching phase was very short for us.
Screeching is unfortunately a common first means of communication, and I can wholly understand why you want to discourage that.
One way to teach it is to encourage her and interact with joy when the makes all other kinds of sounds, to let her know that these are sounds that please you. When she makes these ear-piercing shrieks, show her your discomfort - distort your face, cover your ears, wail or moan, and tell her in plain spoken language "that hurt." Even at her young age, she'll eventually understand that there is a difference.
One of the things kids don't like is a loss of interaction. My son started screeching really loudly, and our reacting with discomfort only made him do it more. Children like to control things, and it's natural for them to do what they can do to make people react. There's no point in getting angry and upset as they genuinely don't understand at their age, so I decided to try and provide feedback in the form of controlling interaction. Every time he screeched I looked away until he stopped, then I looked back. That worked for awhile, but then he did it again and looking away didn't stop him, he just did it louder, so every time he screeched I walked out of the room until he stopped, then I came back in. It did not take long for him to figure it out, and within 2-3 days he stopped and I never had to do anything like that ever again.
In order for interaction control to work you have to react quickly do an association forms: as soon as he starts screeching you leave the room and go where they can't see you, and as soon as they stop you come back in. If you do it promptly and consistently they learn to associate the behavior with something they don't like, leading to them stopping the behavior. If you don't do it consistently or wait until your child's been screeching (or whatever other behavior) for 10 minutes then you'll just confuse your child.
You can't convince a 4 month old to stop a behavior using words, they just don't get it. Interaction is a powerful way to communicate what you want, give more for positive behavior and less for negative behavior. It's much more constructive then getting angry, and it works.