I wrote this snippet recently to compare the edited files in a shelveset with an arbitrary checked-in version of the same files. It's another example of how to use the API to show differences. See How to compare (diff) trees at different versions using the API for a different example of comparing checked-in files.
If you are just getting started with the version control API, you'll want to start with the basic example.