How can I set a file extension to open with my application?

Also how would I handle the file that it opens with?