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. Associating an extension to a MFC application - advanced

Associating an extension to a MFC application - advanced

Scheduled Pinned Locked Moved C / C++ / MFC
c++help
10 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.
  • B Offline
    B Offline
    BadJerry
    wrote on last edited by
    #1

    I want to associate an extension to my MFC application - I know I can call RegisterShellFileType which will do some of that. My problem is that for a given extension, I do not want to start a new instance of my application... I'd like the current instance (ideally all instances but let's not get there right away) to be notified that they need to read the file. If you're wondering why I want this : let me explain. I have this SDI application that creates documents (for lack of a better word). I want the users to be able to download some plugins (with the remarkable extension) from the wwww- and when they open the file from their browser, I want those plugins to be installed... I hope I am making sense! Thanks in advance!

    L I 2 Replies Last reply
    0
    • B BadJerry

      I want to associate an extension to my MFC application - I know I can call RegisterShellFileType which will do some of that. My problem is that for a given extension, I do not want to start a new instance of my application... I'd like the current instance (ideally all instances but let's not get there right away) to be notified that they need to read the file. If you're wondering why I want this : let me explain. I have this SDI application that creates documents (for lack of a better word). I want the users to be able to download some plugins (with the remarkable extension) from the wwww- and when they open the file from their browser, I want those plugins to be installed... I hope I am making sense! Thanks in advance!

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      You would need to configure this into the browser so it recognises the file type and passes that file to the relevant application.

      B 1 Reply Last reply
      0
      • L Lost User

        You would need to configure this into the browser so it recognises the file type and passes that file to the relevant application.

        B Offline
        B Offline
        BadJerry
        wrote on last edited by
        #3

        I respectfully disagree - it should be an Explorer settings - the browser simply asking if you want to save or open the file...

        L 1 Reply Last reply
        0
        • B BadJerry

          I want to associate an extension to my MFC application - I know I can call RegisterShellFileType which will do some of that. My problem is that for a given extension, I do not want to start a new instance of my application... I'd like the current instance (ideally all instances but let's not get there right away) to be notified that they need to read the file. If you're wondering why I want this : let me explain. I have this SDI application that creates documents (for lack of a better word). I want the users to be able to download some plugins (with the remarkable extension) from the wwww- and when they open the file from their browser, I want those plugins to be installed... I hope I am making sense! Thanks in advance!

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

          As I see it, you have two issues... 1/ You want a website, with files of some custome format (call it fwibble.badjerry). In the same way as a (eg) pdf, the browser will run an external application - badjerry.exe, or acrobatreader.exe. 2/ You only ever want one of these programs running, even if they click on multiple files. I hope that's a reasonable summary. 1/ Is a non issue - use RegisterShellFileType as normal. Whether the file comes from a website, via a temp directory, or it comes from the users My Dcuments directory is irrelevant. 2/ Is marginally harder, but there are several erticles on codeproject dealing with single instance applications, and their headaches. An article I've recently used to good effect was: Limiting an application to a single Instance - the MFC way[^]. I did find a bug with huge impact but a simple fix - look at my comment at the end of the article. Other than that, it was a joy to use. Just a daft error. Enjoy, Iain.

          I have now moved to Sweden for love (awwww). If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need cotract work done, give me a job! http://cv.imcsoft.co.uk/[^]

          B M 2 Replies Last reply
          0
          • I Iain Clarke Warrior Programmer

            As I see it, you have two issues... 1/ You want a website, with files of some custome format (call it fwibble.badjerry). In the same way as a (eg) pdf, the browser will run an external application - badjerry.exe, or acrobatreader.exe. 2/ You only ever want one of these programs running, even if they click on multiple files. I hope that's a reasonable summary. 1/ Is a non issue - use RegisterShellFileType as normal. Whether the file comes from a website, via a temp directory, or it comes from the users My Dcuments directory is irrelevant. 2/ Is marginally harder, but there are several erticles on codeproject dealing with single instance applications, and their headaches. An article I've recently used to good effect was: Limiting an application to a single Instance - the MFC way[^]. I did find a bug with huge impact but a simple fix - look at my comment at the end of the article. Other than that, it was a joy to use. Just a daft error. Enjoy, Iain.

            I have now moved to Sweden for love (awwww). If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need cotract work done, give me a job! http://cv.imcsoft.co.uk/[^]

            B Offline
            B Offline
            BadJerry
            wrote on last edited by
            #5

            It's not exactly what I want : the badjerry.exe is not single instance - it can open many .pdf or .doc files but if it tries to open a .badjerry the exisiting instance should be used. But you gave me an idea of how I could implement this - I could associate the .badjerry extension to another single instance program which will then relay the information to the other instances... or start one if there isn't... it's a bit long-winded but... hey... Thanks for your help!

            I 1 Reply Last reply
            0
            • B BadJerry

              It's not exactly what I want : the badjerry.exe is not single instance - it can open many .pdf or .doc files but if it tries to open a .badjerry the exisiting instance should be used. But you gave me an idea of how I could implement this - I could associate the .badjerry extension to another single instance program which will then relay the information to the other instances... or start one if there isn't... it's a bit long-winded but... hey... Thanks for your help!

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

              OK, I'm confused. Unless badjerry.exe is a browser in its own right, it as no business opening pdf files... (I assume it's not a pdf viewer). And if it only handles .badjerry's, then the article I gave you a link to handles that - if a 2nd instance opens, it communicated with the first, to get the first one to open the desired file, then close the 2nd one. Iain.

              I have now moved to Sweden for love (awwww). If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need cotract work done, give me a job! http://cv.imcsoft.co.uk/[^]

              1 Reply Last reply
              0
              • I Iain Clarke Warrior Programmer

                As I see it, you have two issues... 1/ You want a website, with files of some custome format (call it fwibble.badjerry). In the same way as a (eg) pdf, the browser will run an external application - badjerry.exe, or acrobatreader.exe. 2/ You only ever want one of these programs running, even if they click on multiple files. I hope that's a reasonable summary. 1/ Is a non issue - use RegisterShellFileType as normal. Whether the file comes from a website, via a temp directory, or it comes from the users My Dcuments directory is irrelevant. 2/ Is marginally harder, but there are several erticles on codeproject dealing with single instance applications, and their headaches. An article I've recently used to good effect was: Limiting an application to a single Instance - the MFC way[^]. I did find a bug with huge impact but a simple fix - look at my comment at the end of the article. Other than that, it was a joy to use. Just a daft error. Enjoy, Iain.

                I have now moved to Sweden for love (awwww). If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need cotract work done, give me a job! http://cv.imcsoft.co.uk/[^]

                M Offline
                M Offline
                Michael Schubert
                wrote on last edited by
                #7

                Iain Clarke, Warrior Programmer wrote:

                2/ Is marginally harder, but there are several erticles on codeproject dealing with single instance applications, and their headaches. An article I've recently used to good effect was: Limiting an application to a single Instance - the MFC way[^].

                The procedure from that article seems awfully complicated. I always use this code in InitInstance (if it's a MFC app, otherwise WinMain):

                CreateMutex(NULL, TRUE, _T("Unique_String_Identifying_The_Application"));
                if (GetLastError() == ERROR_ALREADY_EXISTS)
                {
                //already running, get out
                return FALSE;
                }

                I 1 Reply Last reply
                0
                • M Michael Schubert

                  Iain Clarke, Warrior Programmer wrote:

                  2/ Is marginally harder, but there are several erticles on codeproject dealing with single instance applications, and their headaches. An article I've recently used to good effect was: Limiting an application to a single Instance - the MFC way[^].

                  The procedure from that article seems awfully complicated. I always use this code in InitInstance (if it's a MFC app, otherwise WinMain):

                  CreateMutex(NULL, TRUE, _T("Unique_String_Identifying_The_Application"));
                  if (GetLastError() == ERROR_ALREADY_EXISTS)
                  {
                  //already running, get out
                  return FALSE;
                  }

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

                  That's what I used to do to... But that does nothing about running the previous (only) instance, let alone get the 1st instance to open any document that the 2nd instance had been... instantiated... to do. Iain.

                  I have now moved to Sweden for love (awwww). If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need cotract work done, give me a job! http://cv.imcsoft.co.uk/[^]

                  M 1 Reply Last reply
                  0
                  • I Iain Clarke Warrior Programmer

                    That's what I used to do to... But that does nothing about running the previous (only) instance, let alone get the 1st instance to open any document that the 2nd instance had been... instantiated... to do. Iain.

                    I have now moved to Sweden for love (awwww). If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need cotract work done, give me a job! http://cv.imcsoft.co.uk/[^]

                    M Offline
                    M Offline
                    Michael Schubert
                    wrote on last edited by
                    #9

                    It was slightly off topic, I guess. I'm still not quite sure what exactly the OP wants...

                    1 Reply Last reply
                    0
                    • B BadJerry

                      I respectfully disagree - it should be an Explorer settings - the browser simply asking if you want to save or open the file...

                      L Offline
                      L Offline
                      Lost User
                      wrote on last edited by
                      #10

                      BadJerry wrote:

                      I respectfully disagree - it should be an Explorer settings - the browser simply asking if you want to save or open the file...

                      Sorry, but your original question was not clear. You mention associating a file type with your application, then talk about downloading files and sending them to your application. Could you clarify exactly how you expect this process to operate, including the interaction (or interdependency) between your application and the browser?

                      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