you can try using white vinegar to dissolve the corrosion....it will do a better job than WD-40.
Some tips from a flashlight forum (adapt them to fit your situation as appropriate - I would try the vinegar first to get rid of as much corrosion as possible - then try the screw pulling technique):
How to get the batteries out that have corroded:
1. Find a #10 self tapping hex head steel screw 2" long.
2. Measure down the barrel how far the battery is.
3. Get an extension for your drill (battery drill prefered) to allow the screw to be power screwed into the battery.
4a. Before power drilling the self tapping screw into the battery, ensure that you have some very long needle nosed pliers or vise grips that will reach the screw, otherwise figure something out that can pull the screwed battery out, e.g. small chain, or steel wire.
4b. Pour some 3 in 1 oil down the barrel to assist the release of the battery. Ensure that battery is adequately flooded with oil.
5. Place maglite into bench mounted vise. Wrap something soft around it first, such as an old towel or rag. Make sure that the vise-gripping area is NOT at the same location as the stuck battery.
6. Power drive the self tapping screw into the battery. If using a small chain, put screw through end of chain first. (may have to use a few washers, etc..)
7. Make sure that you can pull with lots of strength and the maglite won't pull out of the vise. (test pull the lite)
8. Pull the battery out of the barrel using vise grips grabbing the screw, or the chain attached to the screw.
9. With the battery out, flush the barrel with isopropyl alcohol to get the oil out. Allow to dry. OK to jam a rag down there to dry also.
10. Take a broom handle and tape some 80-100-150 grit sandpaper to it. Sand the inside of the barrel to remove corrosion. Gently test inside diameter of barrel with another non-leaky junk battery.
11. Flush maglite with lots of clear running water to remove debris. Flush with isopropyl alcohol to absorb water, and let air dry overnight open.
12. Reassemble the next day.
Note that even if you wreck the trackpad getting them out - if they are name-brand (Duracell or Energizer) you can contact the battery mfgr and they will replace the item that was destroyed (see their website for their guarantee).