Microsoft KB Archive/198906

{|
 * width="100%"|

BUG: GetPrivateProfileSection Opens INI File in Read/Write Mode

 * }

Q198906

-

The information in this article applies to:


 * Microsoft Win32 Application Programming Interface (API), on platform(s):
 * Microsoft Windows 95
 * Microsoft Windows 98

-

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 this to be a bug in the Microsoft products listed at the beginning of this article.

Additional query words:

Keywords : kbKernBase kbRegistry kbOSWin95 kbOSWin98

Issue type : kbbug

Technology : kbAudDeveloper kbWin32sSearch kbWin32API