The 19-year-old poked in from six yards after Bees goalkeeper Ran Kadoch had failed to hold a Lee Bell corner eight minutes from time.
It was only Macclesfield's seventh home win of the season and they took the lead after just two minutes when centre-back Nat Brown netted his sixth goal of the season with a towering header.
Macclesfield should have made their first-half dominance count and on the half hour Jordan Hadfield sent a header inches wide.
But Barnet equalised after 54 minutes when Neal Bishop crossed for Albert Adomah to slot home his 10th of the season from close range.
The Silkmen had the final say as Dennis' late winner sealed all three points for Keith Alexander's men and ended Barnet's six-game unbeaten run.