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. Saving configuration option data

Saving configuration option data

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialworkspace
12 Posts 7 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 karmendra_js

    I have configuration dialogbox where the user uses the combo box to select and set the configuration. Now how and where can i save the configuration data. and how to retrive last saved configuration Thanks, KarmU

    M Offline
    M Offline
    Manfred Staiger
    wrote on last edited by
    #3

    You can use the windows registry for storing your data. The platform SDK provides a set of functions to access the registry. Search MSDN. Another way is to store the data in a text file. This is very easy using the MFC class CStdioFile. MS

    K 1 Reply Last reply
    0
    • K karmendra_js

      I have configuration dialogbox where the user uses the combo box to select and set the configuration. Now how and where can i save the configuration data. and how to retrive last saved configuration Thanks, KarmU

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

      karmendra_js wrote: Now how and where can i save the configuration data. and how to retrive last saved configuration There are many option for saving and reteriving the configurations-> [INI] [http://www.codeproject.com/cpp/cinifile.asp](http:// http://www.codeproject.com/cpp/cinifile.asp)[[^](http:// http://www.codeproject.com/cpp/cinifile.asp)] [Registry] look for CRegKey in you local copy of MSDN [Serialize] http://www.codeproject.com/cpp/serialization_primer1.asp[^]

      "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

      K 1 Reply Last reply
      0
      • M Manfred Staiger

        You can use the windows registry for storing your data. The platform SDK provides a set of functions to access the registry. Search MSDN. Another way is to store the data in a text file. This is very easy using the MFC class CStdioFile. MS

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

        i used the following code but it gives assertion failure why? CStdioFile f; char buf[] = "test string"; f.WriteString( buf );

        M 1 Reply Last reply
        0
        • K karmendra_js

          i used the following code but it gives assertion failure why? CStdioFile f; char buf[] = "test string"; f.WriteString( buf );

          M Offline
          M Offline
          Manfred Staiger
          wrote on last edited by
          #6

          You need to open the file before writing to it. Do it this way: CStdioFile file; CString lineOfText; file.Open("C:\\exaplepath\\examplefile.xyz", CFile::modeCreate|CFile::modeReadWrite); lineOfText="This is the first line"; lineOfText+="\r\n"; file.Writestring(lineOfText); lineOfText="This is the second line"; lineOfText+="\r\n"; file.Writestring(lineOfText); file.Close(); MS

          1 Reply Last reply
          0
          • T ThatsAlok

            karmendra_js wrote: Now how and where can i save the configuration data. and how to retrive last saved configuration There are many option for saving and reteriving the configurations-> [INI] [http://www.codeproject.com/cpp/cinifile.asp](http:// http://www.codeproject.com/cpp/cinifile.asp)[[^](http:// http://www.codeproject.com/cpp/cinifile.asp)] [Registry] look for CRegKey in you local copy of MSDN [Serialize] http://www.codeproject.com/cpp/serialization_primer1.asp[^]

            "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

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

            http://www.codeproject.com/cpp/cinifile.asp\[^\] this link doesn't work. and can i get an example code how to use CRegKey class for storing and retriving data. I have around 11 feilds and i want to save them all. thanks.

            T D 2 Replies Last reply
            0
            • K karmendra_js

              http://www.codeproject.com/cpp/cinifile.asp\[^\] this link doesn't work. and can i get an example code how to use CRegKey class for storing and retriving data. I have around 11 feilds and i want to save them all. thanks.

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

              karmendra_js wrote: _http://www.codeproject.com/cpp/cinifile.asp_ just try http://www.codeproject.com/cpp/cinifile.asp

              "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
              • K karmendra_js

                I have configuration dialogbox where the user uses the combo box to select and set the configuration. Now how and where can i save the configuration data. and how to retrive last saved configuration Thanks, KarmU

                A Offline
                A Offline
                Ashok Dhamija
                wrote on last edited by
                #9

                You can consider using the Registry to save your configuration data. Proceed as under (with MFC): 1. Use functions such as SetRegistryKey, WriteProfileString (for a string), WriteProfileInt (for int), GetProfileString, GetProfileInt, etc., of the application class for setting and accessing values from the Registry. 2. You can consider the Constructor or InitDialog functions wherein the stored values can be retrieved from Registry and displayed in the Configuration dialogbox. 3. Use OnOK (or whatever other button-event-handlers) to save the changed configuation data to registry. 4. Use these stored values appropriately in the code to change your program response. For example, use PreCreateWindow function of the mainframe class to change the position or size of main window using stored configuration data. Regards, Ashok Dhamija _____________________________ Padam Technologies

                1 Reply Last reply
                0
                • K karmendra_js

                  http://www.codeproject.com/cpp/cinifile.asp\[^\] this link doesn't work. and can i get an example code how to use CRegKey class for storing and retriving data. I have around 11 feilds and i want to save them all. thanks.

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

                  karmendra_js wrote: http://www.codeproject.com/cpp/cinifile.asp this link doesn't work. Did you not notice the extra stuff in the URL? Try it again but remove the extraneous characters.


                  "One must learn from the bite of the fire to leave it alone." - Native American Proverb

                  1 Reply Last reply
                  0
                  • K karmendra_js

                    I have configuration dialogbox where the user uses the combo box to select and set the configuration. Now how and where can i save the configuration data. and how to retrive last saved configuration Thanks, KarmU

                    A Offline
                    A Offline
                    Achim Klein
                    wrote on last edited by
                    #11

                    Hi, honestly I don't like Bill's registry very much... If I need to store any configuration data this is my preferred way. Regards Achikm Klein


                    We can do no great things, only small things with great love. - Mother Theresa

                    T 1 Reply Last reply
                    0
                    • A Achim Klein

                      Hi, honestly I don't like Bill's registry very much... If I need to store any configuration data this is my preferred way. Regards Achikm Klein


                      We can do no great things, only small things with great love. - Mother Theresa

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

                      Achim Klein wrote: honestly I don't like Bill's registry very much... Yeap Nice, But still you using Bill's Window for storing the data ?

                      "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
                      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