GetProfileSection

  DWORD GetProfileSection(lpszSection, lpszReturnBuffer, cchBuffer)    
  LPCTSTR lpszSection; /* address of the section name */
  LPTSTR lpszReturnBuffer; /* address of the return buffer */
  DWORD cchBuffer; /* size of the return buffer */

This function retrieves all of the key name and value pairs for a particular section from the WIN.INI file.

Parameters

lpszSection

Points to a null-terminated string containing the section heading in the WIN.INI file.

lpszReturnBuffer

Points to the 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.

cchBuffer

Specifies the size, in characters, of the buffer at lpszReturnBuffer.

Return Value

The return value specifies the number of characters copied to lpszReturnBuffer, not including the terminating null character. If the buffer is not large enough to contain all the key name and value pairs associated with the named application section, the return value is equal to the length specified by the cchBuffer parameter minus 2.

Comments

The GetProfileSection function may be used as either a wide-character function (where text arguments must use Unicode) or an ANSI function (where text arguments must use characters from the Windows 3.x character set installed).

The format of the returned key name and value pairs is one or more null terminated strings, terminated by the final null character. Each string has the following format:

KeyName=Value

GetProfileSection is not case-dependent, so the strings in lpszSection may be in any combination of uppercase and lowercase letters.

This operation is atomic; no updates to the WIN.INI file are allowed while the key name and value pairs for the application section are being copied to the lpszReturnBuffer buffer.

See Also

GetPrivateProfileSection, GetProfileSection, GetProfileInt, GetProfileString, WriteProfileString, WriteProfileSection