This paper presents an extension of the Poincare-Hopf theorem to generalized critical points of a function on a compact region with nonsmooth boundary, M, defined by a finite number of smooth inequality constraints. Given a function F: M -> R", we define the generalized critical points of F over M, define the index for the critical point, and show that the sum of the indices of the critical points is equal to the Euler characteristic of M. We use the generalized Poincare-Hopf theorem to present sufficient (local) conditions for the uniqueness of solutions to finite-dimensional variational inequalities and the uniqueness of stationary points in nonconvex optimization problems.