Actually there are five things that can happen when you get a djinni from a magic lamp:
  • You get a wish
  • The djinni is tame ("Thank you for freeing me!")
  • The djinni is peaceful ("You freed me!")
  • The djinni vanishes ("It is about time!")
  • The djinni is hostile ("You disturbed me, fool!")
The probability of each outcome depends on whether the lamp is blessed, uncursed or cursed, but even when it is blessed your chance of a wish is only 80%.

          Blessed  Uncursed  Cursed

Wish        80%       20%       5%
Tame         5%       20%       5%
Peaceful     5%       20%       5%
Vanishes     5%       20%       5%
Hostile      5%       20%      80%

Once the djinni is released, the magic lamp becomes an oil lamp. Recharging a magic lamp does nothing. Recharging an oil lamp increases the number of turns of light left in it, but does not convert it into a magic lamp.

A magic lamp is more expensive than an oil lamp. It has a list price of 50 GP in Nethack and 1000 GP in Slash'EM. It can be used as an everlasting light source if you're prepared to do without the wish.