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. VC++ code to read and write to an INI file

VC++ code to read and write to an INI file

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorial
20 Posts 6 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.
  • A anna mathew

    Is it easier to create INI file in REGISTRY then READ/WRITE TO it?

    C Offline
    C Offline
    CPallini
    wrote on last edited by
    #10

    For your kind of application, the registry shouldn't be used. :)

    If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
    This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
    [My articles]

    A 1 Reply Last reply
    0
    • A anna mathew

      i need to find the BEST and EASIEST method to CREATE/READ/WRITE INI file

      C Offline
      C Offline
      CPallini
      wrote on last edited by
      #11

      Reading and writing to a INI file it is very simple. You can easily make a 'test' INI file, using, for instance the notepad, and then write to (or read from) programmatically. Check out one of the articles I linked in one of my previous replies to see (in the source files) some sample code. :)

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
      [My articles]

      A 1 Reply Last reply
      0
      • C CPallini

        For your kind of application, the registry shouldn't be used. :)

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
        [My articles]

        A Offline
        A Offline
        anna mathew
        wrote on last edited by
        #12

        Why cant i use registry???? can u tell me please.... im quite IGNORANT abt all these

        C 1 Reply Last reply
        0
        • A anna mathew

          Why cant i use registry???? can u tell me please.... im quite IGNORANT abt all these

          C Offline
          C Offline
          CPallini
          wrote on last edited by
          #13

          Well, you actually can, but you definitely shouldn't. The registry should be used for maintainig application settings (i.e. few data), not as application general data storage (i.e. big amount of data). :)

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
          [My articles]

          A 1 Reply Last reply
          0
          • C CPallini

            Reading and writing to a INI file it is very simple. You can easily make a 'test' INI file, using, for instance the notepad, and then write to (or read from) programmatically. Check out one of the articles I linked in one of my previous replies to see (in the source files) some sample code. :)

            If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
            This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
            [My articles]

            A Offline
            A Offline
            anna mathew
            wrote on last edited by
            #14

            Yes i did check all those links.... thanks..it was helpful... but it all tells abt WIN32 CONSOLE Application... whereas i need.... MFC Application

            C 1 Reply Last reply
            0
            • A anna mathew

              I went through all the codes and sites.... BUt its all WIN32 CONSOLE application... what i want is MFC Application... The other programs i got is MFC Application.........but... It just reads an INI file...thats already created... Im using Visual Studio 2003..... Visual Studio 2008 supports CIniFile.... but the lower versions dont.... so is there any direct....or easy way to READ/WRITE INI file... Other than using the CIniFile code availabe in this forum????

              D Offline
              D Offline
              Doc Lobster
              wrote on last edited by
              #15

              You must redirect the CWinApp application data storage from the registry to your ini file. See the MSDN documentation on CWinApp::m_pszRegistryKey and CWinApp::m_pszProfileName. By freeing m_pszRegistryKey and setting m_pszProfileName to an appropiate path you will be able to use CWinApp::GetProfileString CWinApp::GetProfileInt CWinApp::WriteProfileInt CWinApp::WriteProfileString on an ini file instead of the registry. When I switched my application to use an .ini file, this took me a while to find out. However, it's not likely we are the first people to face this issue ... there must be an example somewhere. :~

              A 1 Reply Last reply
              0
              • C CPallini

                Well, you actually can, but you definitely shouldn't. The registry should be used for maintainig application settings (i.e. few data), not as application general data storage (i.e. big amount of data). :)

                If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                [My articles]

                A Offline
                A Offline
                anna mathew
                wrote on last edited by
                #16

                Ok ..thank u

                1 Reply Last reply
                0
                • A anna mathew

                  Yes i did check all those links.... thanks..it was helpful... but it all tells abt WIN32 CONSOLE Application... whereas i need.... MFC Application

                  C Offline
                  C Offline
                  CPallini
                  wrote on last edited by
                  #17

                  For the purpose of read/write to a INI file, the fact it is negligible. BTW are you able to code a very simple MFC application? :)

                  If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                  This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                  [My articles]

                  A 1 Reply Last reply
                  0
                  • D Doc Lobster

                    You must redirect the CWinApp application data storage from the registry to your ini file. See the MSDN documentation on CWinApp::m_pszRegistryKey and CWinApp::m_pszProfileName. By freeing m_pszRegistryKey and setting m_pszProfileName to an appropiate path you will be able to use CWinApp::GetProfileString CWinApp::GetProfileInt CWinApp::WriteProfileInt CWinApp::WriteProfileString on an ini file instead of the registry. When I switched my application to use an .ini file, this took me a while to find out. However, it's not likely we are the first people to face this issue ... there must be an example somewhere. :~

                    A Offline
                    A Offline
                    anna mathew
                    wrote on last edited by
                    #18

                    Yes i read abt it..... thank you.... I got the right answer that i was looking for

                    1 Reply Last reply
                    0
                    • C CPallini

                      For the purpose of read/write to a INI file, the fact it is negligible. BTW are you able to code a very simple MFC application? :)

                      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                      [My articles]

                      A Offline
                      A Offline
                      anna mathew
                      wrote on last edited by
                      #19

                      Yes... i can... Ive done MFC database programming too....

                      C 1 Reply Last reply
                      0
                      • A anna mathew

                        Yes... i can... Ive done MFC database programming too....

                        C Offline
                        C Offline
                        CPallini
                        wrote on last edited by
                        #20

                        anna mathew wrote:

                        Yes... i can...

                        Wow, like Obama. :rolleyes:

                        anna mathew wrote:

                        Ive done MFC database programming too....

                        Then shouldn't be difficult for you to have a look at the (console) article and adapt the code to the MFC application. Good luck. :)

                        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                        [My articles]

                        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