Help with GetPrivateProfileSectionNames

This is a discussion on Help with GetPrivateProfileSectionNames within the Windows Programming forums, part of the Platform Specific Boards category; I used GetPrivateProfileSectionNames to retrieve a list of the section names. The only problem is that I now have all ...

  1. #1
    Registered User
    Join Date
    Jun 2006
    Posts
    5

    Help with GetPrivateProfileSectionNames

    I used GetPrivateProfileSectionNames to retrieve a list of the section names. The only problem is that I now have all the names stored into one char array seperated by \0s. What would be the best/easiest way to split the string up into individual char arrays. Also note that there won't be a set number of section names. Thanks for any help.

  2. #2
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,059
    IMHO, ini's have been made obsolete by the registry. So, it's been a long time since I've worked with ini's. But I believe the following code snippet may be helpful.

    Code:
    #define MAX 8192
    
    void ReadSections(char* IniPath)
    {
        LPTSTR lpszReturnBuffer;
        lpszReturnBuffer = new TCHAR[MAX];
        char* pNextSection = NULL;
           GetPrivateProfileSectionNames(lpszReturnBuffer,MAX,IniPath);
        pNextSection = lpszReturnBuffer;
        printf("%s\n", pNextSection);      
        while (*pNextSection != 0x00)
        {
            pNextSection = pNextSection + strlen(pNextSection) + 1;
            if(*pNextSection != 0x00)
            {
                printf("%s\n", pNextSection);
            }
        }
    }

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21