We show that the complex and projective structures on 2D Riemann surfaces are determined by the solutions to the linear differential equations obtained by the hamiltonian reduction of Sl(2,C) connections by the gauge parabolic subgroup. The compatibility of complex (mu) and projective (T) structures appears as the associated zero-curvature condition on the reduced symplectic manifold and is nothing but the conformal Ward identity. Generalizing this construction to the reduction of Sl(n, C) connections by the maximal parabolic gauge subgroup, we obtain generalized complex (mu, rho,...) and projective (T, W,... ) structures. From their compatibility conditions we explicitly obtain the Ward identities of W(n)-gravity and the operator product expansions of the W(n)-algebras. The associated linear differential equations (one of which involves the basic differential operator of the nth reduction of the KP hierarchy) allow for a geometric interpretation of the W-symmetries in terms of deformations of flag configurations in the jet bundle GAMMA(n-1). We also show how to derive the W(n)-Ward identities from the quantization of the (2 + l)-dimensional Chern-Simons theory.