Updating Multiple Device= Lines in SYSTEM.INI

Last reviewed: July 23, 1997
Article ID: Q107695
3.00 3.10 WINDOWS kbprg

The information in this article applies to:

  • Microsoft Windows Software Development Kit (SDK) for Windows versions 3.0 and 3.1

SUMMARY

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.

MORE INFORMATION

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",
   "SYSTEM.INI");

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.

    -or-

  • 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.

    -or-

  • 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 reference words: 3.10 3.00
KBCategory: kbprg
KBSubcategory: UsrIni
Keywords : kb16bitonly


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 23, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.