Updating Cached Private Profiles (.INI Files)Last reviewed: July 22, 1997Article ID: Q68827 |
3.00 3.10
WINDOWS
kbprg SR# G910109-169
The information in this article applies to:
SUMMARYUnder Windows version 3.1, the first time a private profile (.INI file) is accessed, the system will call the GetFileTime() API and store this value. The WriteProfileString() API will then call the GetFileTime() API and compare the return value to the stored value. If the two values match, the file is considered valid for two seconds. The function makes the changes and writes the new contents to disk. If the two values do not match, the profile is reread into a buffer and the change is made. The same principle holds true for reading values from a private profile. The reasoning behind the two second limit is that most applications read private profiles in a burst, at application startup, and write in a burst, at application shutdown. The penalty of one read in a twenty read sequence is considered acceptable, given the benefits. In Windows version 3.0, an application that has a private profile will not respond to changes made to that private profile by a text editor. When a text editor updates a private profile, the file on disk is modified. However, GetPrivateProfileString() and GetPrivateProfileInt() do not read from the disk file, instead the functions read from a copy of the file in a cache. WritePrivateProfileString() will update the appropriate sections in both the cached file and the disk file, however, the functions will not reload the disk file into the cache unless the entire cache is invalidated. The information included below discusses how to force a private profile to be recached from a disk file.
MORE INFORMATIONWindows caches .INI files to reduce access time. This design allows the file to remain in memory until a different .INI file is loaded or until an application forces recaching of the file. To force an .INI file to be recached, make the following call (where <fname.ini> is the name of the application's private profile):
WritePrivateProfileString(NULL, NULL, NULL, <fname.ini>)This call will force the entire .INI file that is in the cache to be invalidated. The next call to either GetPrivateProfileString() or GetPrivateProfileInt() will cause the disk file to be recached. While .INI files are cached to optimize access time, the following are examples of how and when an .INI file could be recached.
|
Additional reference words: 3.00 3.10 3.x SR# G910109-169
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |