Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. "open with"...

"open with"...

Scheduled Pinned Locked Moved C#
tutorial
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sammyh
    wrote on last edited by
    #1

    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

    H 1 Reply Last reply
    0
    • S sammyh

      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

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      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

      S S 2 Replies Last reply
      0
      • H Heath Stewart

        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

        S Offline
        S Offline
        SJ_Phoenix
        wrote on last edited by
        #3

        thanks...I needed that too :)

        1 Reply Last reply
        0
        • H Heath Stewart

          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

          S Offline
          S Offline
          sammyh
          wrote on last edited by
          #4

          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

          H 1 Reply Last reply
          0
          • S sammyh

            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

            H Offline
            H Offline
            Heath Stewart
            wrote on last edited by
            #5

            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

            S 1 Reply Last reply
            0
            • H Heath Stewart

              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

              S Offline
              S Offline
              sammyh
              wrote on last edited by
              #6

              Exactly what I was looking for, thanks

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups