When to Use WIN.INI or a Private INI File

Last reviewed: July 22, 1997
Article ID: Q74608
3.00 3.10 WINDOWS kbprg

The information in this article applies to:

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

SUMMARY

An application should use a private profile (INI) file to store initialization information where possible rather than the main INI file in Windows, WIN.INI. Profile files are not designed for use as a database or a mass-storage device.

MORE INFORMATION

Applications use the profile functions in the Windows application programming interface (API) to save and retrieve initialization settings. The following profile functions are used with WIN.INI:

   GetProfileInt
   GetProfileString
   WriteProfileString

Until Windows version 3.0, applications stored their initialization data in only one global place (WIN.INI). Windows version 3.0 added a complimentary set of functions to the Windows API to enable an application to store its initialization data in a private INI file. These functions are as follows:

   GetPrivateProfileInt
   GetPrivateProfileString
   WritePrivateProfileString

The following factors provided the motivation for the addition of private INI files:
  • INI files are limited to 64K in size.
  • Windows ignores the portion of INI files past 64K. Therefore, if enough applications use WIN.INI rather than separate, private INI files, some of the user's INI data may be ignored.
  • No consistent way exists for users to remove old, unneeded information from the WIN.INI file. Typically, when an application is removed from the system, the files are deleted from the application's directory. However, the corresponding information may not be deleted from WIN.INI. Alternately, if initialization data is stored in a private INI file in the application's directory or in a file with the application's name, the user is much more likely to delete the obsolete information.
  • Windows uses a linear search to find information in INI files. Therefore, smaller INI files provide faster performance.

By default, INI files are created in the Windows directory. However, an application should always use a fully qualified path to a different directory because the Windows system directory is a shared resource in a Windows network setup.

Do not use the private profile functions with the WIN.INI file. Windows caches a copy of WIN.INI and one private INI file. This caching scheme may be confused if WIN.INI is altered using the private profile functions.

Applications should use INI files conservatively. Use as few sections and as few lines as possible. For example, do not save the coordinates of a window individually, as follows:

   [window save pos]
   ul = 10
   ur = 10
   ll = 100
   lr = 100

Instead, use one line, as follows:

   [save_pos]
   window=10 10 100 100

This is a more efficient use of space and is much faster.


Additional reference words: 3.00 3.10
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 22, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.