Establish, read, store Ini files "three"

zhaozj2021-02-16  48

Control INI file

To use the .ini file to do the program's storage work, you need to read and write .ini files, so listed the following method for your reference:

Get strings from .ini files

VAR

Strresult: pchar;

Begin

GetPrivateProfileString

The name of the title of 'windows', // []

The name before 'Nullport', // =

'Nil', // If you do not find a string, the default value returned

Strresult, // Store gets characters

100, // Get the maximum length of the character

'c: /forwin95/win.ini' // The file name called

);

Edit1.Text: = Strresult; // Display getting string

Get an integer from the .ini file

Edit1.text: = INTTOSTR (GetPrivateProfileint

The name of 'Intl', // []

'ICOUNTRY', / / ​​= Name

0, // If an integer is not found, the default value returned

'c: /forwin95/win.ini' // The file name called

));

Write the .ini file into the string

WriteprivateProfileString

The name of the title of 'windows', // []

'load', // To write the string before "="

'accca', // to write data

'c: /forwin95/win.ini' // The file name called

);

Write an integer to .ini file

WritePrivateProfileSecion

The name of the title of 'windows', // []

'read = 100', // To write data

'c: /forwin95/win.ini' // The file name called

);

The above method is to call the API function, which is described below with another method that does not have to get characters from the .ini file.

Var myini: tinifile;

Begin

Myini: = tinifile.create ('win.ini'); // Call file name

Edit1.text: = Myini.ReadString ('Desktop', 'Wallpaper', '); // Get Character

END;

Method for writing characters in .ini file

Var myini: tinifile;

Begin

Myini: = tinifile.create ('win.ini'); // Call file name

Delphiini.writestring ('Desktop', 'Wallpaper'); 'C: /A.BMP');

END;

转载请注明原文地址:https://www.9cbs.com/read-24973.html

New Post(0)