Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Reading and Writing to .INI files.
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00242096
Message ID:
00242137
Views:
23
>I'm looking for the best way to read and write to an .INI file. I have come up with using low level functions FGET(), FPUT(), or using the REGFN() function available in Foxtools.dll. I can't help but think that there is a better way to do this...
>
>Thanks for any responses in advance.
The WIN32API provides functions for reading and writing INI files.

To read from an INI file use
DECLARE INTEGER GetPrivateProfileString IN Win32API AS GetPrivStr ;
String cSection, String cKey, String cDefault, String @cBuffer, ;
Integer nBufferSize, String cINIFile

cSection is the name of the section in the INI file.
cKey is the name of the key you want to read.
cDefault is the default value to return if the key does not exist.
cBuffer is a string buffer to receive the key value.
nBufferSize is the size of cBuffer.
cINIFile is the path of the INI file.

cBuffer will be terminated with a null character [CHR(0)] you will need to substring the result to get rid of it.

To write to an INI file use
DECLARE INTEGER WritePrivateProfileString IN Win32API AS WritePrivStr ;
String cSection, String cKey, String cValue, String cINIFile
Steve Ruhl
CitiMortgage, Inc.
steven.ruhl@citibank.com Office
Steve@steven-ruhl.com Home
Previous
Reply
Map
View

Click here to load this message in the networking platform