views:

32

answers:

4

Hi,

I wrote an application which will be able to open files of particular extension and show it to users. Now I want the users to be able to just double click the file and have it open with my application. I tried to set the "Always use the selected program..." option in the windows "Open With" dialog box, but do not know how to receive the file name that Windows sends to my application. How to do this?

Thanks...

A: 

You should receive the filename in your application's startup parameters

Riho
A: 

Windows passes the filename as a startup parameter to your application. You will need to handle this in your WinMain or application entry point.

t0ne
+2  A: 

The file name will be passed to your application as an argument. For example, in c#, you will get it like this:

static class Program

[STAThread]
static void Main(string[] args)
{
  if (args.Length > 0)
  {
    string filename = args[0];
  }
}
Magnus Johansson
+1  A: 

if i understand well. u need to make something like

~ Notpad test.txt

so u need to make optional argument in ur application so if it is exist than will open the file , if not open new file.

Mohamed Ziada