"open with"...
-
Could someone please point me to some info on the how to make my app open a file when it is double clicked in explorer. Thank you, Sam
Then why is your subject entitled "Open with..."? This is what happens when you DON'T have an association. File associations are easy. See Creating a File Association[^] in the Platform SDK. This can easily be incorporated into an installer, too. See previous posts in this forum (click "Search comments") for information about how to do this correctly with a Windows Installer package.
Microsoft MVP, Visual C# My Articles
-
Then why is your subject entitled "Open with..."? This is what happens when you DON'T have an association. File associations are easy. See Creating a File Association[^] in the Platform SDK. This can easily be incorporated into an installer, too. See previous posts in this forum (click "Search comments") for information about how to do this correctly with a Windows Installer package.
Microsoft MVP, Visual C# My Articles
thanks...I needed that too :)
-
Then why is your subject entitled "Open with..."? This is what happens when you DON'T have an association. File associations are easy. See Creating a File Association[^] in the Platform SDK. This can easily be incorporated into an installer, too. See previous posts in this forum (click "Search comments") for information about how to do this correctly with a Windows Installer package.
Microsoft MVP, Visual C# My Articles
Sweet, that shows how to link an extension to the application, set the icon for the extension, and extend the shell, but... How do I handle the link in my app? Do I need to test for a registry entry, is the program called with arguments, do I override function? I can't find anything on this subject. Thanks again for the help. -Sam
//you know you've been coding for too long when you hit Ctrl-Shift-B instead of submit
-
Sweet, that shows how to link an extension to the application, set the icon for the extension, and extend the shell, but... How do I handle the link in my app? Do I need to test for a registry entry, is the program called with arguments, do I override function? I can't find anything on this subject. Thanks again for the help. -Sam
//you know you've been coding for too long when you hit Ctrl-Shift-B instead of submit
When you double-click on the file, Windows Explorer executes your application and passes the path to the file as the first argument. So lets say you have a
FilePath
property on your main application form, and/or a constructor which takes the path of the file. You could do something like this:public class MainForm : Form
{
static void Main(string[] args)
{
MainForm form = null;
if (args.Length > 0)
form = new MainForm(args[0]);
else
form = new MainForm();
Application.Run(form);
}
public MainForm() : this(null)
{
}
public MainForm(string filePath)
{
this.filePath = filePath;
}
private string filePath;
public string FilePath
{
get { return this.filePath; }
set { this.filePath = value; }
}
}Microsoft MVP, Visual C# My Articles
-
When you double-click on the file, Windows Explorer executes your application and passes the path to the file as the first argument. So lets say you have a
FilePath
property on your main application form, and/or a constructor which takes the path of the file. You could do something like this:public class MainForm : Form
{
static void Main(string[] args)
{
MainForm form = null;
if (args.Length > 0)
form = new MainForm(args[0]);
else
form = new MainForm();
Application.Run(form);
}
public MainForm() : this(null)
{
}
public MainForm(string filePath)
{
this.filePath = filePath;
}
private string filePath;
public string FilePath
{
get { return this.filePath; }
set { this.filePath = value; }
}
}Microsoft MVP, Visual C# My Articles