Using a directional form of constraint qualification weaker than Robinson's, we derive an implicit function theorem for inclusions and we use it for first and second order sensitivity analysis of the value function in perturbed constrained optimization. We obtain Holder and Lipschitz properties and, under a no gap condition, first order expansions for exact and approximate solutions. As an application, differentiability properties of metric projections in Hilbert spaces are obtained, using a condition generalizing polyhedricity. We also present in appendix a short proof of a generalization of the convex duality theorem in Banach spaces.