there are two ways. One, you associate your app with a file type by writing a registry entry, your app is set to be called with command line args so it can detect what was clicked on
Or you can as Stonkie suggests, write a DLL that windows will ask "do you handle this type of file? if so, what are your menu entries because the user is right clicking" and thats a lot harder
You can also possibly use a utlitity called Mmm