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 / C++ / MFC
  4. How to execute an external program based on file extension

How to execute an external program based on file extension

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++tutorial
6 Posts 4 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.
  • W Offline
    W Offline
    William Engberts
    wrote on last edited by
    #1

    Hi all, I have an MFC program that (amongst others) stores some files with different types (like .msg, .doc, .eml etc) When the user selects one such files, I would like to start the relevant software to open that file much like what happens when I doubleclick on a file from the explorer. How do I do such a thing? (one: how do I find-out which program to start based on the file's extension and two: what is the easiest way to start that program?) Thanks in advance William

    N K I 3 Replies Last reply
    0
    • W William Engberts

      Hi all, I have an MFC program that (amongst others) stores some files with different types (like .msg, .doc, .eml etc) When the user selects one such files, I would like to start the relevant software to open that file much like what happens when I doubleclick on a file from the explorer. How do I do such a thing? (one: how do I find-out which program to start based on the file's extension and two: what is the easiest way to start that program?) Thanks in advance William

      N Offline
      N Offline
      Niklas L
      wrote on last edited by
      #2

      I think you're looking for the ShellExecute[^] API.

      home

      W 1 Reply Last reply
      0
      • W William Engberts

        Hi all, I have an MFC program that (amongst others) stores some files with different types (like .msg, .doc, .eml etc) When the user selects one such files, I would like to start the relevant software to open that file much like what happens when I doubleclick on a file from the explorer. How do I do such a thing? (one: how do I find-out which program to start based on the file's extension and two: what is the easiest way to start that program?) Thanks in advance William

        K Offline
        K Offline
        KingsGambit
        wrote on last edited by
        #3

        ShellExecuteEx() would automatically open the associated program based on the file type.

        1 Reply Last reply
        0
        • W William Engberts

          Hi all, I have an MFC program that (amongst others) stores some files with different types (like .msg, .doc, .eml etc) When the user selects one such files, I would like to start the relevant software to open that file much like what happens when I doubleclick on a file from the explorer. How do I do such a thing? (one: how do I find-out which program to start based on the file's extension and two: what is the easiest way to start that program?) Thanks in advance William

          I Offline
          I Offline
          Iain Clarke Warrior Programmer
          wrote on last edited by
          #4

          I know you mean "execute" in a computing context, ie "run". But I had a different picture when I saw your subject heading. exe -> *Bang!* txt -> *chop!* doc -> *defenestrate!* Iain.

          I am one of "those foreigners coming over here and stealing our jobs". Yay me!

          W 1 Reply Last reply
          0
          • N Niklas L

            I think you're looking for the ShellExecute[^] API.

            home

            W Offline
            W Offline
            William Engberts
            wrote on last edited by
            #5

            Thanks a lot. This indeed solved my issue. Regards, William

            1 Reply Last reply
            0
            • I Iain Clarke Warrior Programmer

              I know you mean "execute" in a computing context, ie "run". But I had a different picture when I saw your subject heading. exe -> *Bang!* txt -> *chop!* doc -> *defenestrate!* Iain.

              I am one of "those foreigners coming over here and stealing our jobs". Yay me!

              W Offline
              W Offline
              William Engberts
              wrote on last edited by
              #6

              Although there are definately certain files that I would gladly *kill*, *exterminate*, etc You are right in assuming that my question was intended to be boringly technical.

              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