Mike's answer is broadly true but there are some variations, certainly in the UK.
What actually appears on the controller's radar display depends on a number of things (including which company built the radar processing software). In most cases the aircraft id, if it was on a discrete code and had been code/callsign converted (i.e. the display showed the callsign rather than the mode A code) in the display software, will remain displayed but some early systems don't do this.
As Mike says, if you are already talking to ATC tell them you have a problem and if there's a good reason to squawk emergency they'll tell you to. In some circumstances the controller will get an aircraft to put up 7700, if it's making an emergency descent for example, so that other controllers know that it may not do what is normally expected (and will try to keep their own aircraft out of the way).
There are lots of other specific situations where 7700 is the best squawk but the controller will know, and tell you, if there is a benefit in changing code. If there is no benefit he/she won't give you something unnecessary to do when you've already got your hands full!
If you're not talking to a controller and ATC might be able to help the best answer is to put 7700 up and speak to the nearest secondary radar equipped ATC unit (or D & D) to declare your emergency.
And I hope you never have to do it.