MainFrm.pas
上传用户:psxgmh
上传日期:2013-04-08
资源大小:15112k
文件大小:2k
- unit MainFrm;
- interface
- uses
- Windows, Messages, SysUtils, Classes, Graphics,
- Controls, Forms, Dialogs, inifiles, StdCtrls, ExtCtrls, Spin;
- type
- TfrmMain = class(TForm)
- edtAppName: TEdit;
- CHBBeta: TCheckBox;
- Label1: TLabel;
- Label2: TLabel;
- Label3: TLabel;
- SEYear: TSpinEdit;
- btnWirte: TButton;
- procedure FormCreate(Sender: TObject);
- procedure btnWirteClick(Sender: TObject);
- procedure FormDestroy(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- frmMain: TfrmMain;
- implementation
- var
- myinifile: TInifile;
- {$R *.DFM}
- procedure TfrmMain.FormCreate(Sender: TObject);
- var
- filename: string;
- begin
- filename := ExtractFilePath(paramstr(0)) + 'TestINI.ini';
- if not FileExists(fileName) then
- raise Exception.Create('TestINI文件不存在');
- //打开配置文件
- MyINIFile := TINIFile.Create(filename);
- //读取配置文件
- edtAppName.Text := myinifile.readstring('参数配置一', 'AppName', '');
- SEYear.text := inttostr(myinifile.readinteger('参数配置一', 'APPYear', 0));
- CHBBeta.Checked := myinifile.readbool('参数配置一', 'AppBeta', False);
- end;
- procedure TfrmMain.btnWirteClick(Sender: TObject);
- begin
- //写入配置文件
- myinifile.writestring('参数配置一', 'APPName', edtAppName.Text);
- myinifile.writeinteger('参数配置一', 'APPYear', strtoint(SEYear.text));
- myinifile.writebool('参数配置一', 'APPBeta', CHBBeta.Checked);
- end;
- procedure TfrmMain.FormDestroy(Sender: TObject);
- begin
- //释放MyINIFile
- MyINIFile.Free;
- end;
- end.