The London side's fate was sealed last week, and they were playing for nothing but pride against Burnley on Saturday.
But an impressive strike from 18-year-old Marvin Williams just before the break earned three points.
McLeary, who was appointed joint caretaker along with Tony Burns in midweek following David Tuttle's resignation, said: "I'm thrilled with the win to get the club off the bottom, but the performance was excellent as well.
"The lads that we picked are the future of this club, and they have lifted the spirits of the supporters. We needed to lift the crowd after the week we've had and we certainly did that.
"The supporters of this club have always appreciated effort and when they get that they get behind their team and I'd like to thank them for that."