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. GetProfileString creates a key automatically

GetProfileString creates a key automatically

Scheduled Pinned Locked Moved C / C++ / MFC
questionwindows-adminhelptutorialworkspace
3 Posts 3 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.
  • B Offline
    B Offline
    beko
    wrote on last edited by
    #1

    Hello, I am using GetProfileString to read from registry, the registry keys are created via setup and i should check if there is an option set, and the program should act accordingly. For example; MyApplication Data Data01 I have to check if Data01 available, if yes then read its setting from the registry, otherwise do the default handling. However when i check if Data01 available, GetProfileString creates that entry for me :), if that entry is there no problem but if it is not, then it automatically creates. You can see how i am trying to check.

    CString category(_T("Data\\"));
    category+=dataCode; // DataCode could be Data01 or Data02 i dont know this before hand.
    path = GetProfileString(category,_T("InitPath"));

    How should i check if an entry there using GetProfileString or how can i do it? Thanks in advance. Bekir.

    D S 2 Replies Last reply
    0
    • B beko

      Hello, I am using GetProfileString to read from registry, the registry keys are created via setup and i should check if there is an option set, and the program should act accordingly. For example; MyApplication Data Data01 I have to check if Data01 available, if yes then read its setting from the registry, otherwise do the default handling. However when i check if Data01 available, GetProfileString creates that entry for me :), if that entry is there no problem but if it is not, then it automatically creates. You can see how i am trying to check.

      CString category(_T("Data\\"));
      category+=dataCode; // DataCode could be Data01 or Data02 i dont know this before hand.
      path = GetProfileString(category,_T("InitPath"));

      How should i check if an entry there using GetProfileString or how can i do it? Thanks in advance. Bekir.

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

      beko wrote:

      How should i check if an entry there using GetProfileString or how can i do it?

      Use RegQueryValue() for the registry.

      "Love people and use things, not love things and use people." - Unknown

      "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

      1 Reply Last reply
      0
      • B beko

        Hello, I am using GetProfileString to read from registry, the registry keys are created via setup and i should check if there is an option set, and the program should act accordingly. For example; MyApplication Data Data01 I have to check if Data01 available, if yes then read its setting from the registry, otherwise do the default handling. However when i check if Data01 available, GetProfileString creates that entry for me :), if that entry is there no problem but if it is not, then it automatically creates. You can see how i am trying to check.

        CString category(_T("Data\\"));
        category+=dataCode; // DataCode could be Data01 or Data02 i dont know this before hand.
        path = GetProfileString(category,_T("InitPath"));

        How should i check if an entry there using GetProfileString or how can i do it? Thanks in advance. Bekir.

        S Offline
        S Offline
        sashoalm
        wrote on last edited by
        #3

        See 'Checking Existence of Keys and Values' in this[^] article.

        There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition. Blaise Pascal

        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