This is far from being a simple problem, and this kind of problems are active areas of research in computer science (more specifically, in image processing and machine learning). A colleague of mine (PhD) worked on this for a while, until she gave up and changed her supervisor.
I think that the starting point for you should be OpenCV, which is a C++ library that can do a lot of image processing stuff (filtering, feature detection, etc.). I don't think they have a facial expression detector (but they do have "face detectors", e.g., the kind used for webcam effects like giving you a hat or a beard or a different face). They also probably have easy ways to track face features like eyes, ears, and outline of the mouth. But, translating that into making any sense of what a particular facial expression is (i.e., the emotion), that's the hard part. A quick search reveals this tutorial.
ya i know i am also starting with basic face detection,after which i have to use PCA or gabor wavelets for which im using open cv only,but the thing is i want to do everything on windows platform only preferably ms visual cpp.i want to know any basic face detection algorithm and how to implement it by programming on own ,not by just calling a inbuilt function
Work out the math, and then convert that to software. Also, this will be easier to do with Linux than Windows (in my opinion). If you haven't mastered the math to detect facial expressions from raw data, then you have no hope of succeeding in this quest. It is a good project, but an advanced graduate level one at best.