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. Registering a file type

Registering a file type

Scheduled Pinned Locked Moved C / C++ / MFC
tutorial
8 Posts 2 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.
  • K Offline
    K Offline
    KRowe
    wrote on last edited by
    #1

    I am writing a simple NFO file viewer and I need additional information on how to create the file association. Does anyone know any good tutorials on this. Additionally, since the NFO file type is set for the MSInfo application by default in Win it may have special considerations. Any information about additional concerns I should have would also be useful.

    D 1 Reply Last reply
    0
    • K KRowe

      I am writing a simple NFO file viewer and I need additional information on how to create the file association. Does anyone know any good tutorials on this. Additionally, since the NFO file type is set for the MSInfo application by default in Win it may have special considerations. Any information about additional concerns I should have would also be useful.

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

      You did not specify whether you were using MFC or not. If you are, check out CWinApp::EnableShellOpen() and CWinApp::RegisterShellFileTypes(). If you are not, here is a .reg file from an app that I wrote called RegWatch. You would simply need to replace "regwatch" (and variations of) with the name of your app and "rw" with the extension you want to register.

      REGEDIT
      ; This .REG file may be used by your SETUP program.
      ; If a SETUP program is not available, the entries below will be
      ; registered in your InitInstance automatically with a call to
      ; CWinApp::RegisterShellFileTypes and COleObjectFactory::UpdateRegistryAll.

      HKEY_CLASSES_ROOT\.rw = RegWatch.Document
      HKEY_CLASSES_ROOT\RegWatch.Document\shell\open\command = REGWATCH.EXE %1
      HKEY_CLASSES_ROOT\RegWatch.Document\shell\open\ddeexec = [open("%1")]
      HKEY_CLASSES_ROOT\RegWatch.Document\shell\open\ddeexec\application = REGWATCH
      ; note: the application is optional
      ; (it defaults to the app name in "command")

      HKEY_CLASSES_ROOT\RegWatch.Document = RegWat Document


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

      K 1 Reply Last reply
      0
      • D David Crow

        You did not specify whether you were using MFC or not. If you are, check out CWinApp::EnableShellOpen() and CWinApp::RegisterShellFileTypes(). If you are not, here is a .reg file from an app that I wrote called RegWatch. You would simply need to replace "regwatch" (and variations of) with the name of your app and "rw" with the extension you want to register.

        REGEDIT
        ; This .REG file may be used by your SETUP program.
        ; If a SETUP program is not available, the entries below will be
        ; registered in your InitInstance automatically with a call to
        ; CWinApp::RegisterShellFileTypes and COleObjectFactory::UpdateRegistryAll.

        HKEY_CLASSES_ROOT\.rw = RegWatch.Document
        HKEY_CLASSES_ROOT\RegWatch.Document\shell\open\command = REGWATCH.EXE %1
        HKEY_CLASSES_ROOT\RegWatch.Document\shell\open\ddeexec = [open("%1")]
        HKEY_CLASSES_ROOT\RegWatch.Document\shell\open\ddeexec\application = REGWATCH
        ; note: the application is optional
        ; (it defaults to the app name in "command")

        HKEY_CLASSES_ROOT\RegWatch.Document = RegWat Document


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

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

        Sorry, I am not using MFC. My intention is to make the app as small as possible and a single file. I suppose I would be able to output this to a temp file then run some command to merge it into the registry. Do you know how I would go about merging it into the registry without the messagebox that says "Are you sure you want to add this to the registry?" appearing?

        D 1 Reply Last reply
        0
        • K KRowe

          Sorry, I am not using MFC. My intention is to make the app as small as possible and a single file. I suppose I would be able to output this to a temp file then run some command to merge it into the registry. Do you know how I would go about merging it into the registry without the messagebox that says "Are you sure you want to add this to the registry?" appearing?

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

          KRowe wrote: I suppose I would be able to output this to a temp file... Yes, as long as it has a .reg extension. KRowe wrote: Do you know how I would go about merging it into the registry without the messagebox that says "Are you sure you want to add this to the registry?" appearing? What's wrong with that message? In any case, you could update the registry via code using the registry API, or the CRegKey class?


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

          K 1 Reply Last reply
          0
          • D David Crow

            KRowe wrote: I suppose I would be able to output this to a temp file... Yes, as long as it has a .reg extension. KRowe wrote: Do you know how I would go about merging it into the registry without the messagebox that says "Are you sure you want to add this to the registry?" appearing? What's wrong with that message? In any case, you could update the registry via code using the registry API, or the CRegKey class?


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

            K Offline
            K Offline
            KRowe
            wrote on last edited by
            #5

            Now that I think about it...I guess there is nothing wrong with that. It will work fairly nicely like that. I was wanting to give a more descriptive message but that should be good enough. The registry API looks like it is a huge hassle to work with IMO so I am trying to avoid it or find it already encapsulated. I have found a few MFC classes but apparently nobody uses straight C++ for Windows programming anymore. Ohh well, thanks for the help.

            D 1 Reply Last reply
            0
            • K KRowe

              Now that I think about it...I guess there is nothing wrong with that. It will work fairly nicely like that. I was wanting to give a more descriptive message but that should be good enough. The registry API looks like it is a huge hassle to work with IMO so I am trying to avoid it or find it already encapsulated. I have found a few MFC classes but apparently nobody uses straight C++ for Windows programming anymore. Ohh well, thanks for the help.

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

              KRowe wrote: ...apparently nobody uses straight C++ for Windows programming anymore. Perhaps you meant that nobody uses straight C for Windows programming anymore. Technically, C++ knows nothing of Windows, so it is because of things like MFC, ATL, and WTL that Windows development is so much easier.


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

              K 1 Reply Last reply
              0
              • D David Crow

                KRowe wrote: ...apparently nobody uses straight C++ for Windows programming anymore. Perhaps you meant that nobody uses straight C for Windows programming anymore. Technically, C++ knows nothing of Windows, so it is because of things like MFC, ATL, and WTL that Windows development is so much easier.


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

                K Offline
                K Offline
                KRowe
                wrote on last edited by
                #7

                I'm not exactly sure what you are trying to say. If you are trying to say that technically MFC is C++ then yes you are correct but the MFC library is I think about 1.5 megs that I really have no use for until this little problem. So by straight C++ I meant C++ without additional huge libraries (I know that my includes add some extra baggage but it is still far less than MFC and I'm trying to minimize them as well). I guess that does sound a little too much like the common term "straight C" that is used to differentiate C from C++ but that is not what I meant. I would have to argue with you about weather MFC would have made it much easier to do what I am doing however. All my program does is read a file and output it to the screen with some additional formating that requires me to output a single character at a time. This make the CString class almost useless for this. Additionally, I have no controls and only 2 very simple dialogs in the app (plus a Common Dialog). I guess it's what you're used to but, aside from the CString class and couple other handy features, MFC seems to be more of a hastle than it is worth. I can't tell you how much time I have spent trying to get MFC to not do something or other. True, it is the way to go for medium to very large apps, but for the smaller stuff (like my little text viewer) I prefer not to use it.

                D 1 Reply Last reply
                0
                • K KRowe

                  I'm not exactly sure what you are trying to say. If you are trying to say that technically MFC is C++ then yes you are correct but the MFC library is I think about 1.5 megs that I really have no use for until this little problem. So by straight C++ I meant C++ without additional huge libraries (I know that my includes add some extra baggage but it is still far less than MFC and I'm trying to minimize them as well). I guess that does sound a little too much like the common term "straight C" that is used to differentiate C from C++ but that is not what I meant. I would have to argue with you about weather MFC would have made it much easier to do what I am doing however. All my program does is read a file and output it to the screen with some additional formating that requires me to output a single character at a time. This make the CString class almost useless for this. Additionally, I have no controls and only 2 very simple dialogs in the app (plus a Common Dialog). I guess it's what you're used to but, aside from the CString class and couple other handy features, MFC seems to be more of a hastle than it is worth. I can't tell you how much time I have spent trying to get MFC to not do something or other. True, it is the way to go for medium to very large apps, but for the smaller stuff (like my little text viewer) I prefer not to use it.

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

                  KRowe wrote: I'm not exactly sure what you are trying to say. It's a common misconception that C++ knows about things such as input/output, files, Windows, etc. I was simply clarifying that without extra packages such as STL, WTL, ATL, or MFC, what you are after is not possible. KRowe wrote: (I know that my includes add some extra baggage but it is still far less than MFC and I'm trying to minimize them as well). Unless the code will be running on a cell phone or an older PDA, trying to optimize for size is not a worthy exercise. Thinking about "how big" the code is almost always leads to a lot of effort that produces no payback whatsoever. What matters is how big the data is. This goes back to the days when programmers were taught that "smaller is better." KRowe wrote: I would have to argue with you about weather MFC would have made it much easier to do what I am doing however. All my program does is read a file and output it to the screen with some additional formating that requires me to output a single character at a time. With what you've described so far, I'm seeing a dozen lines of code, maybe two. KRowe wrote: This make the CString class almost useless for this. I've never known CString to be useless for much of anything. Do you have an example? KRowe wrote: Additionally, I have no controls and only 2 very simple dialogs in the app How can you have a dialog without any controls?


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

                  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