My PC's ATX power supply stopped working. I opened it and noticed that it makes a high pitch sound when turned on. I can't figure out which component in the power supply makes that sound, so that I can replace it.
WARNING - PC Power supplies have lethal voltages internally both when mains voltage is applied and also for a variable period of time after being turned off.
If you don't know what you are doing and what precautions to take then if you "play" with such devices you may not live long enough to learn.
The most likely source of the noise is "magnetostriction" of the switched mode power supply transformer core. The core is driven at excessive currents and/or with an unusual waveform and acts as an audio transducer as the core is magneticallly squeezed thn released by the alternating current.
It is likely that the fault is not in the core itself but is caused by either oscillations being at a lower than usual frequency and/or the supply being overloaded by a fault.
Be aware that outputs MAY be non mains isolated. They are usually but ... .
Turn supply OFF. Connect DC meter to a psu output. Turn on psu. Measure voltage. Repeat for all outputs.
Remove mains power.
Examine the pcb, looking for unusual signs.
Main power supply caps are a good start to look at - but expensive to replace.
Discharging high voltage capacitors:
Capacitors can remain charged for hours in some cases.
If there is a concern that capacitors may have retained charge they can be discharged by "shorting" or (preferably) by using a resistor with two probes.
Don't try this at home if not competent and confident with such things. Eye damage (wear goggles) and electric shock are a possible danger.
WARNING - Capacitors that have been discharged can "regrow" some charge after a while. This can be enough to give you a shock. Two dischargings a few minutes apart is usually enough to remove most of the charge but be aware of the possibility.
The sound could come from a capacitor or a transformer, though that is not necessarily the part that is defective.
Personally I wouldn't mess with a switched power supply (it is very dangerous and a repair is unlikely to succeed) and buy a new one.
How exactly has it stopped working?
It is quite likely a coil/transformer that is whining due to a e.g. shorted output transistor, bad capacitors or faulty load, causing excess current/pulse skipping which produces audible frequencies. Make sure you have removed all the loads to confirm they are not the problem.