Jump to content


GetPrivateProfileSection question!


  • You cannot reply to this topic
No replies to this topic

#1 Hyper

    Valued Member

  • Members
  • PipPipPip
  • 193 posts

Posted 14 July 2009 - 05:44 AM

I'm sure there's an easy answer to this, and I'm half asleep (which is probably why I'm post). This is rather easy to answer for anyone, and I'm quite aware that there's the Windows Registry but I don't want to use that. I want this to be more user-friendly, and I've recently realized that (like AutoIt), C++ has predefined *.ini control functions (or however you'd refer to that). Pretty much I can write/read specific strings from an *.ini file. I can write "Sections" (which are in brackets) and that's great! But say I wanted to write something that was X long (user defined and edited). Like...

Quote

[Messages]
1=Hi
2=How
3=Are
4=You?

You couldn't get 1-4 statically using GetPrivateProfileString, but with GetPrivateProfileSection you could! Because it runs through and collects them all (although I'm unsure how), which is why I'm posting here. :)

How do you extract the information from GetPrivateProfileSection?

Thanks in advance (I'm trying to figure out right now). :unsure:

----------------------------- EDIT ------------------------------------
        for (int x = 0; x < 500; x++) {

            printf("%c", test[x]);


            if (test[x] == '\0') {

                printf("\n"); // New line - the string ended

                if (test[x + 1] == '\0') { break; }

            }

        }

Fixed! :) I'm such a retard... Thanks, sorry for the post.
It clearly states here (http://msdn.microsof...348(VS.85).aspx) on MSDN:

Quote

lpReturnedString [out]

A pointer to a buffer that receives the key name and value pairs associated with the named section. The buffer is filled with one or more null-terminated strings; the last string is followed by a second null character.

Sorry for posting, thanks again!!! <3
“You may be disappointed if you fail, but you are doomed if you don't try.”
Beverly Sills





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users