BUG: GetPrivateProfileSection Opens INI File in Read/Write Mode
Article ID: 198906
Article Last Modified on 11/21/2006
APPLIES TO
- Microsoft Win32 Application Programming Interface, when used with:
- Microsoft Windows 98 Standard Edition
- Microsoft Windows Millennium Edition
This article was previously published under Q198906
SYMPTOMS
GetPrivateProfileSection sometimes returns 0, even though the specified section is contained in the initialization file.
CAUSE
The GetPrivateProfileSection API opens the initialization file with read and write access. If the initialization file is read only, this function returns 0.
RESOLUTION
You can resolve this error by making a call to GetPrivateProfileString before GetPrivateProfileSection. Make the GetPrivateProfileString call as follows before calling any other profile functions:
char buffer[4096];
GetPrivateProfileString(NULL, NULL, NULL,
buffer, sizeof(buffer), "ABC.INI");
The profile functions are provided for compatibility with 16-bit applications written for Windows. It is recommended that all Win32-based applications store initialization information in the registry and use the Win32 registry APIs to retrieve these values.
STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.
Keywords: kbbug kbkernbase kbregistry KB198906