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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to open file in own program?

How to open file in own program?

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
8 Posts 5 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.
  • U Offline
    U Offline
    uus99
    wrote on last edited by
    #1

    Hi, I have a file that i want to associate it with my program. Then, if i double click it in explorer, it should automatically open in my program. What event should i handle? How to do this? Usman

    C T D 3 Replies Last reply
    0
    • U uus99

      Hi, I have a file that i want to associate it with my program. Then, if i double click it in explorer, it should automatically open in my program. What event should i handle? How to do this? Usman

      C Offline
      C Offline
      cancerion
      wrote on last edited by
      #2

      i thing using ShellExecute function this could be done

      1 Reply Last reply
      0
      • U uus99

        Hi, I have a file that i want to associate it with my program. Then, if i double click it in explorer, it should automatically open in my program. What event should i handle? How to do this? Usman

        T Offline
        T Offline
        ThatsAlok
        wrote on last edited by
        #3

        uus99 wrote:

        I have a file that i want to associate it with my program. Then, if i double click it in explorer, it should automatically open in my program.

        you have to associate the file extention with your program... for that you have to change entry in HKEY_CLASSES_ROOT in registry

        "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

        cheers, Alok Gupta VC Forum Q&A :- I/ IV

        U 1 Reply Last reply
        0
        • T ThatsAlok

          uus99 wrote:

          I have a file that i want to associate it with my program. Then, if i double click it in explorer, it should automatically open in my program.

          you have to associate the file extention with your program... for that you have to change entry in HKEY_CLASSES_ROOT in registry

          "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

          cheers, Alok Gupta VC Forum Q&A :- I/ IV

          U Offline
          U Offline
          uus99
          wrote on last edited by
          #4

          Hi, once i associate the the file extension, which function will be called if i open the file in explorer? I mean, for example, my program is Program.exe, and the file is file.zzz. I associate the files *.zzz to my program, and if i open it in explorer, which function in my program will it be called?? OnOpen() etc?? Do i have to add an event handler? THanks, Usman

          T C 2 Replies Last reply
          0
          • U uus99

            Hi, once i associate the the file extension, which function will be called if i open the file in explorer? I mean, for example, my program is Program.exe, and the file is file.zzz. I associate the files *.zzz to my program, and if i open it in explorer, which function in my program will it be called?? OnOpen() etc?? Do i have to add an event handler? THanks, Usman

            T Offline
            T Offline
            ThatsAlok
            wrote on last edited by
            #5

            :doh::sigh:

            uus99 wrote:

            if i open it in explorer, which function in my program will it be called?? OnOpen() etc?? Do i have to add an event handler

            If you have created SDI/MDI based application, Document/view architecture will handle it for you! you have to overide OnOpen Function (I forget the actual Handller or Function :doh::sigh:)

            "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

            cheers, Alok Gupta VC Forum Q&A :- I/ IV

            1 Reply Last reply
            0
            • U uus99

              Hi, once i associate the the file extension, which function will be called if i open the file in explorer? I mean, for example, my program is Program.exe, and the file is file.zzz. I associate the files *.zzz to my program, and if i open it in explorer, which function in my program will it be called?? OnOpen() etc?? Do i have to add an event handler? THanks, Usman

              C Offline
              C Offline
              Cedric Moonen
              wrote on last edited by
              #6

              To complete the answer of Alok, in fact what really happen is that your program is called with the name of the file passed as command line argument. But, like Alok said, if it is a SDI or MDI app, the framework will handle all the job for you (it will call automatically the serialize methods thus loading the file). But of course, you have to implement the loading,saving of data in the serialize handlers.

              U 1 Reply Last reply
              0
              • U uus99

                Hi, I have a file that i want to associate it with my program. Then, if i double click it in explorer, it should automatically open in my program. What event should i handle? How to do this? Usman

                D Offline
                D Offline
                David Crow
                wrote on last edited by
                #7

                See here.


                "Take only what you need and leave the land as you found it." - Native American Proverb

                1 Reply Last reply
                0
                • C Cedric Moonen

                  To complete the answer of Alok, in fact what really happen is that your program is called with the name of the file passed as command line argument. But, like Alok said, if it is a SDI or MDI app, the framework will handle all the job for you (it will call automatically the serialize methods thus loading the file). But of course, you have to implement the loading,saving of data in the serialize handlers.

                  U Offline
                  U Offline
                  uus99
                  wrote on last edited by
                  #8

                  WHat about dialog based programs? My project is a dialog based project, and i wan to associate TIFF files so that it opens in my program.

                  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