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. how to use WriteProfileString and GetProfileString MFC functions???

how to use WriteProfileString and GetProfileString MFC functions???

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorialquestion
9 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.
  • A Offline
    A Offline
    anna mathew
    wrote on last edited by
    #1

    Can someone tell me how to use WriteProfileString and GetProfileString mFC functions???? this is my CODE... it executes....But Data not getting WRITTEN to INI file.... why????????? code: void CFileApp::OnView() { free((void*)m_pszProfileName); m_pszProfileName=_strdup(_T("C:\\MyFile.ini")); WriteProfileString("1", "Name", "MATHEW"); }

    H CPalliniC 2 Replies Last reply
    0
    • A anna mathew

      Can someone tell me how to use WriteProfileString and GetProfileString mFC functions???? this is my CODE... it executes....But Data not getting WRITTEN to INI file.... why????????? code: void CFileApp::OnView() { free((void*)m_pszProfileName); m_pszProfileName=_strdup(_T("C:\\MyFile.ini")); WriteProfileString("1", "Name", "MATHEW"); }

      H Offline
      H Offline
      Hamid Taebi
      wrote on last edited by
      #2

      I think you asked similar questions some days ago I think this article is helpful for you.CIniFile[^].

      1 Reply Last reply
      0
      • A anna mathew

        Can someone tell me how to use WriteProfileString and GetProfileString mFC functions???? this is my CODE... it executes....But Data not getting WRITTEN to INI file.... why????????? code: void CFileApp::OnView() { free((void*)m_pszProfileName); m_pszProfileName=_strdup(_T("C:\\MyFile.ini")); WriteProfileString("1", "Name", "MATHEW"); }

        CPalliniC Offline
        CPalliniC Offline
        CPallini
        wrote on last edited by
        #3

        anna mathew wrote:

        WriteProfileString

        As I told to you many, many, many, many, many times, WriteProfileString writes to the registry (from this [^] MSDN page)

        Remarks The entries are stored as follows: * In Windows NT, the value is stored to a registry key. * In Windows 3.x, the value is stored in the WIN.INI file. * In Windows 95/98, the value is stored in a cached version of WIN.INI.

        Use Win32 API's WritePrivateProfileString instead. :)

        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]

        In testa che avete, signor di Ceprano?

        A L 3 Replies Last reply
        0
        • CPalliniC CPallini

          anna mathew wrote:

          WriteProfileString

          As I told to you many, many, many, many, many times, WriteProfileString writes to the registry (from this [^] MSDN page)

          Remarks The entries are stored as follows: * In Windows NT, the value is stored to a registry key. * In Windows 3.x, the value is stored in the WIN.INI file. * In Windows 95/98, the value is stored in a cached version of WIN.INI.

          Use Win32 API's WritePrivateProfileString instead. :)

          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
          #4

          Ya,... now i know.... thanks...

          1 Reply Last reply
          0
          • CPalliniC CPallini

            anna mathew wrote:

            WriteProfileString

            As I told to you many, many, many, many, many times, WriteProfileString writes to the registry (from this [^] MSDN page)

            Remarks The entries are stored as follows: * In Windows NT, the value is stored to a registry key. * In Windows 3.x, the value is stored in the WIN.INI file. * In Windows 95/98, the value is stored in a cached version of WIN.INI.

            Use Win32 API's WritePrivateProfileString instead. :)

            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
            #5

            how can i prevent overwriting to INI file....?? I mean Is There Any WAY TO CHECK IF THE SECTION NAME... [section name] already exists???

            CPalliniC 1 Reply Last reply
            0
            • A anna mathew

              how can i prevent overwriting to INI file....?? I mean Is There Any WAY TO CHECK IF THE SECTION NAME... [section name] already exists???

              CPalliniC Offline
              CPalliniC Offline
              CPallini
              wrote on last edited by
              #6

              Yes, there is GetPrivateProfileSectionNames [^]. BTW: Be aware, you're just a step aside the feared RTFM. :)

              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]

              In testa che avete, signor di Ceprano?

              1 Reply Last reply
              0
              • CPalliniC CPallini

                anna mathew wrote:

                WriteProfileString

                As I told to you many, many, many, many, many times, WriteProfileString writes to the registry (from this [^] MSDN page)

                Remarks The entries are stored as follows: * In Windows NT, the value is stored to a registry key. * In Windows 3.x, the value is stored in the WIN.INI file. * In Windows 95/98, the value is stored in a cached version of WIN.INI.

                Use Win32 API's WritePrivateProfileString instead. :)

                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]

                L Offline
                L Offline
                larsho
                wrote on last edited by
                #7

                Hi, maybe this is not so simple after all. The MSDN page says that WriteProfileString will write to the application's registry OR .INI file. In my case, when I compile in XP using VisualC++ 6.0 the string is written to C:/WINDOWS/myappl.INI. I can find nothing in the registry. Transferring the project to Vista and using visual Studio 2008, my application does not come up with a remembered string, the default is used instead. Nothing is found in the registry and I have found no myappl.INI file after running the appl a few times with a valid string.

                CPalliniC 1 Reply Last reply
                0
                • L larsho

                  Hi, maybe this is not so simple after all. The MSDN page says that WriteProfileString will write to the application's registry OR .INI file. In my case, when I compile in XP using VisualC++ 6.0 the string is written to C:/WINDOWS/myappl.INI. I can find nothing in the registry. Transferring the project to Vista and using visual Studio 2008, my application does not come up with a remembered string, the default is used instead. Nothing is found in the registry and I have found no myappl.INI file after running the appl a few times with a valid string.

                  CPalliniC Offline
                  CPalliniC Offline
                  CPallini
                  wrote on last edited by
                  #8

                  In fact what the OP needs could be simply accomplished using WritePrivateProfileString. :)

                  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]

                  In testa che avete, signor di Ceprano?

                  L 1 Reply Last reply
                  0
                  • CPalliniC CPallini

                    In fact what the OP needs could be simply accomplished using WritePrivateProfileString. :)

                    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]

                    L Offline
                    L Offline
                    larsho
                    wrote on last edited by
                    #9

                    Hi, yes, I noticed that in the discussion, but I am first trying to understand where the WriteProfileString is actually writing things. The MSDN text is saying this OR that, but not much about what is steering where things go. As I understand it, you should call CWinApp::SetRegistryKey if you want to have things in the registry "Causes application settings to be stored in the registry instead of INI files". I get further confused when the application is not working either way in Vista, no registry and no INI file.

                    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