Google is your friend: It's called "Associating an application with a file extension" and there are a couple of ways to do it. Normally, you'd do it as part of your installation process so that it's all set up when your app is prepped to run on the system, but there are ways to do that in your application as well.
Google "associate my app with a file type"[
^] should give you plenty of examples.