Microsoft KB Archive/107695

From BetaArchive Wiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

PRB: Updating Multiple Device= Lines in SYSTEM.INI


3.00 3.10 WINDOWS kbprg

The information in this article applies to:

  • Microsoft Windows Software Development Kit (SDK) 3.1


When there is more than one entry with the same name under a section in an .INI file, WritePrivateProfileString() and WriteProfileString() can update only the first specified entry in the section.


This behavior is by design.


For example, in the [386Enh] section of the SYSTEM.INI file, there are multiple "device=" lines. If you want to add a new device= line or update one of the device= lines other than the first device= entry, you cannot use WritePrivateProfileString(). For example, the following call

   WritePrivateProfileString("386Enh", "device", "drvname.drv",

will only replace the first device= statement with DRVNAME.DRV, instead of adding a new device= line. The reason is that the Windows .INI file application programming interfaces (APIs) in the Windows 3.1 SDK work only on unique entries in a given section of the .INI file.

There are couple of options available to work around this situation:

  • Open, parse, modify, and save the .INI file in your application. Note, that although Windows 3.1 supports direct file I/O to the INI files, Windows 3.0 does not. Moreover, Windows caches INI files, and therefore if you modify a .INI file, the disk file is updated, however, the cache is not. To update the cache, call WriteProfileString(NULL, NULL, NULL), which forces a flush of the cache.


  • Win32 applications can use the APIs that support the multiple "entry=" lines in a single section of a .INI file. For example, you could use the WriteProfileSection() and WritePrivateProfileSection() functions in the Win32 API.


  • Use the VxD services that WIN386.EXE uses when it loads all the devices listed in the device= lines of the [386Enh] section in SYSTEM.INI file. The services that the VxDs provide are documented in the Windows Device Driver Kit (DDK).

Additional query words: 3.10 3.00

Keywords : kb16bitonly kbSDKPlatform kbSysSettings
Issue type : kbprb
Technology : kbAudDeveloper kbWin3xSearch kbSDKSearch kbWinSDKSearch kbWinSDK310

Last Reviewed: June 9, 1999
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.