Get string from .INI file
var
strResult:pchar;
begin
GetPrivateProfileString(
´windows´,//The name of the title in []
´NullPort´,//=The name before the number
´NIL´,//If the string is not found, the default value returned
strResult,//Storage the obtained characters
100, //Get the maximum allowed length of characters
´c:/forwin95/win.ini´//The called file name
);
edit1.text:=strResult;//Display the obtained string
Get integer from .INI file
edit1.text:=inttostr(GetPrivateProfileInt(
´intl´,//The name of the title in []
´iCountry´,//=name before number
0, //If no integer is found, the default value returned
´c:/forwin95/win.ini´//The called file name
));
Write string to .INI file
WritePrivateProfileString(
´windows´,//The name of the title in []
´load´,//To write the string before the "=" sign
´accca´,//Data to be written
´c:/forwin95/win.ini´//The called file name
);
Write integers to .INI file
WritePrivateProfileSection(
´windows´,//The name of the title in []
´read=100´,//Data to be written
´c:/forwin95/win.ini´//The called file name
);
The above method is to call the API function. Here is another method to get characters from the .INI file without using the API.
varMyIni:TIniFile;
begin
MyIni:=TIniFile.Create(´WIN.INI´);//The called file name
edit1.text:=MyIni.ReadString(´Desktop´,´Wallpaper´,´´);//Get characters
end;
How to write characters to an .INI file
varMyIni:TIniFile;
begin
MyIni:=TIniFile.Create(´WIN.INI´);//The called file name
DelphiIni.WriteString(´Desktop´,´Wallpaper´,´c:/a.bmp´);
end;