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. Urgent! CFG files

Urgent! CFG files

Scheduled Pinned Locked Moved C / C++ / MFC
question
7 Posts 5 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.
  • M Offline
    M Offline
    mfc_surfer
    wrote on last edited by
    #1

    How can I create a cfg file and read from or write on it? Thanks for helping!

    M I R A 4 Replies Last reply
    0
    • M mfc_surfer

      How can I create a cfg file and read from or write on it? Thanks for helping!

      M Offline
      M Offline
      Michael Dunn
      wrote on last edited by
      #2

      .cfg isn't a standard format, it's just a general "config file" type. For what app are you trying to write a .cfg file? --Mike-- Ericahist | CP SearchBar v2.0.2 | Homepage | RightClick-Encrypt | 1ClickPicGrabber Pinky, are you pondering what I'm pondering? I think so Brain, but how will we fit the hamster inside the accordion?

      1 Reply Last reply
      0
      • M mfc_surfer

        How can I create a cfg file and read from or write on it? Thanks for helping!

        I Offline
        I Offline
        Ian Darling
        wrote on last edited by
        #3

        Further to Michael's answer, it depends on whether you want to use Windows .INI style config files, or XML config files. For the former, take a look at the functions GetPrivateProfileString and WritePrivateProfileString, but note that using these APIs is not really encouraged, as they're intended for 16-bit compatability. For the latter, look at using MSXML or use whatever your choice in XML parsers happens to be. -- Ian Darling "The moral of the story is that with a contrived example, you can prove anything." - Joel Spolsky

        M 2 Replies Last reply
        0
        • M mfc_surfer

          How can I create a cfg file and read from or write on it? Thanks for helping!

          R Offline
          R Offline
          Ravi Bhavnani
          wrote on last edited by
          #4

          Further to Michael's and Ian's replies, see this article if you want to use a custom binary format to read and write configuration data. /ravi Let's put "civil" back in "civilization" Home | Articles | Freeware | Music ravib@ravib.com

          1 Reply Last reply
          0
          • M mfc_surfer

            How can I create a cfg file and read from or write on it? Thanks for helping!

            A Offline
            A Offline
            Anthony_Yio
            wrote on last edited by
            #5

            *.CFG is not a standard used by MFC. MFC usually uses *.INI. *.CFG is for .NET framework. Below is the code for C# to access the *.CFG(refering MSDN) Just change it to Managed C++

            using System;
            using System.Collections;
            using System.Configuration;

            class MyConfigurationReader {

            public void ReadMySettings() {
                IDictionary sampleTable = (IDictionary) 
                    ConfigurationSettings.GetConfig("sampleSection");
                string value1 = (string)sampleTable\["setting1"\];
                string value2 = (string)sampleTable\["setting2"\];
                string value3 = (string)sampleTable\["setting3"\];
            }
            

            }

            Sonork 100.41263:Anthony_Yio

            1 Reply Last reply
            0
            • I Ian Darling

              Further to Michael's answer, it depends on whether you want to use Windows .INI style config files, or XML config files. For the former, take a look at the functions GetPrivateProfileString and WritePrivateProfileString, but note that using these APIs is not really encouraged, as they're intended for 16-bit compatability. For the latter, look at using MSXML or use whatever your choice in XML parsers happens to be. -- Ian Darling "The moral of the story is that with a contrived example, you can prove anything." - Joel Spolsky

              M Offline
              M Offline
              mfc_surfer
              wrote on last edited by
              #6

              I'm going to use that in an MFC application to configure oracle connection. I want to use windows .INI style.

              1 Reply Last reply
              0
              • I Ian Darling

                Further to Michael's answer, it depends on whether you want to use Windows .INI style config files, or XML config files. For the former, take a look at the functions GetPrivateProfileString and WritePrivateProfileString, but note that using these APIs is not really encouraged, as they're intended for 16-bit compatability. For the latter, look at using MSXML or use whatever your choice in XML parsers happens to be. -- Ian Darling "The moral of the story is that with a contrived example, you can prove anything." - Joel Spolsky

                M Offline
                M Offline
                mfc_surfer
                wrote on last edited by
                #7

                Thanks for your reply :) I'm going to use that in an MFC application to configure oracle connection. I want to use windows .INI style.

                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