http://winmerge.org/downloads/source-code.php

Why reinvent the wheel?

Edit: Oops. GPLv2. Sorry. Can't do much with this source code other than to learn some basic concepts from it.