ID: Q102564
2.5x 2.6x 3.00 WINDOWS
The information in this article applies to:
The examples below demonstrate how to read specific information from the Windows .INI files. The first example shows how to read information from the WIN.INI file; the second example shows how to read information from any other Windows .INI file.
NOTE: This article only applies to 16-bit versions of Microsoft Windows (Windows versions 3.x).
This example will read the Load= line from the [Windows] section of the WIN.INI file:
\kbon
SET LIBRARY TO SYS(2004)+"FOXTOOLS.FLL"
MRETURN=REPLICATE(CHR(0), 144)
MREGISTER=REGFN("GETPROFILESTRING","CCC@CI","I")
MCALL=CALLFN(MREGISTER,"WINDOWS","LOAD","",@MRETURN,256)
WAIT WINDOW ALLTRIM(MRETURN)
\kboff
MRETURN is created as a large and empty character variable. This variable is required when calling a function like this one. If we were to omit the line to set up this variable, the function would not work. MRETURN can also be initialized by using SPACE(144) instead of using REPLICATE().
MREGISTER is the variable name that defines the function using the RegFn() function. This example registers the GetProfileString() function and returns a value from the WIN.INI file.
MCALL returns a numeric value after calling the MREGISTER() function. The number returned is the length of the returned string. MRETURN is still going to be the full length that it was originally created.
This example returns the setting of the Load= line under the [Windows] section of the WIN.INI file. If the Load= line does not contain any information, the Default Return value, specified in the MCALL statement after the "LOAD" key name, returns nothing and MCALL equals zero. The Default Return value can be modified to return any character expression.
To read a different section of the WIN.INI file, change "WINDOWS" in the example above to the application name of the section to be read from (for example, "DESKTOP" would indicate the [Desktop] section). In addition, change "LOAD" to reflect the key name to be read (for example, "WALLPAPER" would indicate the Wallpaper= line under the [Desktop] section).
NOTE: Application name and key name are not case sensitive.
This example will read the Color Schemes= line from the [Current] section of the CONTROL.INI file:
\kbon
SET LIBRARY TO SYS(2004)+"FOXTOOLS.FLL"
MRETURN=REPLICATE(CHR(0), 144)
MREGISTER=REGFN("GETPRIVATEPROFILESTRING","CCC@CIC","I")
MCALL=CALLFN(MREGISTER,"CURRENT","COLOR SCHEMES", ;
"",@MRETURN,256,"CONTROL.INI")
WAIT WINDOW ALLTRIM(MRETURN)
\kboff
NOTE: The MCALL lines should be combined to fit on one line.
The commands are almost the same as those in Example 1, except that this example uses the GetPrivateProfileString() function. This function allows any Windows .INI file, other than the WIN.INI file, to be read. Another difference between this example and Example 1 is that you must specify the .INI file to be read. By default, if no path is specified, Windows will look in the Windows program directory (usually C:\WINDOWS) for the .INI file.
Microsoft Windows Software Development Kit "Guide to Programming," version 3.1
Additional reference words: FoxWin VFoxWin 2.50 2.50 2.50a 2.50b 2.60 2.60a 3.00 KBCategory: KBSubcategory: FxprgFoxtools
Keywords : kbcode FxprgFoxtools
Version : 2.5x 2.6x 3.00
Platform : WINDOWS
Last Reviewed: May 22, 1998