Pergunta

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...

Foi útil?

Solução

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];
  }
}

Outras dicas

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.

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

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

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top