It goes both ways.
Often, more competitive high schools send more students to elite universities. Of course, that's because in fact, these high schools are more competitive.
In many instances, going to a poor or underperforming high school gets you points. In the University of California's comprehensivve review process, points are awarded to those coming out of such schools. For other universities seeking diversity who keep profiles of individual schools, they will take the AP situation into account when considering your application. Obviously though, when your surrounded by a weaker student body, your ranking should be higher - a #5 at an underperforming HS is not equal to a #5 at a Massachusetts prep.
Ultimately, adcoms are looking at if you made the most of what your HS has to offer... whatever that is.