As said above, your concerns are not correct. It is documented in MSDN that GetPrivateProfileSectionNames will never return more than 32767 bytes + NUL, so my code does not imply any other limitation than the operating system itself already has.