DELPHI中INI文件的配置问题
配置一个INI文件在窗体打开时能显示某某同学你好的字样.请问,INI文件应该怎么写,在DELPHI里调用INI文件的代码在哪写,怎么写?希望各位高手能写个例子出来,能写的...
配置一个INI文件 在窗体打开时能显示某某同学你好 的字样.请问,INI文件应该怎么写,在DELPHI里调用INI文件的代码在哪写,怎么写?希望各位高手能写个例子出来,能写的详细点,小弟非常感谢~!~
我的油箱是flashkvk@eyou.com 展开
我的油箱是flashkvk@eyou.com 展开
展开全部
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IniFiles, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
MyIniFile: TInifile;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
FileName: string;
tString: string;
begin
Filename := ExtractFilePath(ParamStr(0)) + 'System.ini';
tString := MyIniFile.ReadString('SystemPath','AppPath','None');
if tString = 'None' then
begin
MyInifile.writestring('SystemPath','AppPath',ExtractFilePath(ParamStr(0)));
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
tString: String;
begin
tString := MyIniFile.ReadString('SystemPath','AppPath','None');
messagebox(Handle, pchar(tstring),'我的INI',mb_yesno);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
MyInifile := TInifile.Create('System.ini');
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
MyInifile := Nil;
MyInifile.Free;
end;
end.
你看下吧,这个是我从前做过的例子,如果想要源码的话,可以留下E-Mail我发给你。
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IniFiles, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
MyIniFile: TInifile;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
FileName: string;
tString: string;
begin
Filename := ExtractFilePath(ParamStr(0)) + 'System.ini';
tString := MyIniFile.ReadString('SystemPath','AppPath','None');
if tString = 'None' then
begin
MyInifile.writestring('SystemPath','AppPath',ExtractFilePath(ParamStr(0)));
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
tString: String;
begin
tString := MyIniFile.ReadString('SystemPath','AppPath','None');
messagebox(Handle, pchar(tstring),'我的INI',mb_yesno);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
MyInifile := TInifile.Create('System.ini');
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
MyInifile := Nil;
MyInifile.Free;
end;
end.
你看下吧,这个是我从前做过的例子,如果想要源码的话,可以留下E-Mail我发给你。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询