|
发表于 2009-12-7 11:49:40
|
显示全部楼层
|阅读模式
来自 中国–北京–北京–通州区
随意写的一个,基本代码完整,自己还要什么功能自己加吧。
编译环境:WinXp + SP3 + Delphi 7 + FlatStyle 4.42- unit Unit1;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, FlatBtns, FlatUtils, FlatBoxs, StdCtrls, shellapi, inifiles, FlatCtrls;
- type
- TForm1 = class(TForm)
- FlatEdit1: TFlatEdit;
- FlatEdit2: TFlatEdit;
- FlatEdit3: TFlatEdit;
- FlatEdit4: TFlatEdit;
- FlatButton1: TFlatButton;
- FlatButton2: TFlatButton;
- FlatButton3: TFlatButton;
- FlatEdit5: TFlatEdit;
- OpenDialog1: TOpenDialog;
- FlatCheckBox1: TFlatCheckBox;
- FlatCheckBox2: TFlatCheckBox;
- FlatCheckBox3: TFlatCheckBox;
- FlatComboBox1: TFlatComboBox;
- FlatEdit6: TFlatEdit;
- Label1: TLabel;
- FlatRadioButton1: TFlatRadioButton;
- FlatRadioButton2: TFlatRadioButton;
- Label2: TLabel;
- procedure FlatButton1Click(Sender: TObject);
- procedure FlatButton2Click(Sender: TObject);
- procedure FlatButton3Click(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- Form1: TForm1;
- implementation
- {$R *.dfm}
- procedure TForm1.FlatButton1Click(Sender: TObject);
- begin
- if opendialog1.Execute then
- begin
- FlatEdit4.Text:= opendialog1.FileName;
- end;
- end;
- procedure TForm1.FlatButton2Click(Sender: TObject);
- var
- Filedir,cstrike,console,S,tmp,accel,parms,spd,Physics,refresh,version: string;
- F: TextFile ;
- myini: Tinifile;
- begin
- myini:= Tinifile.Create(ExtractFilePath(Paramstr(0))+'config.ini');
- myini.WriteString('config','cstrike',FlatEdit4.Text);
- myini.WriteString('config','serverip',FlatEdit5.Text);
- myini.WriteString('config','amxxpw',FlatEdit1.Text);
- myini.WriteString('config','user',FlatEdit2.Text);
- myini.WriteString('config','pass',FlatEdit3.Text);
- if FlatCheckBox1.checked then myini.WriteString('other','accel','1') else myini.WriteString('other','accel','0');
- if FlatCheckBox2.checked then myini.WriteString('other','parms','1') else myini.WriteString('other','parms','0');
- if FlatCheckBox3.checked then myini.WriteString('other','spd','1') else myini.WriteString('other','spd','0');
- myini.WriteString('other','Physics',FlatComboBox1.Text);
- myini.WriteString('other','refresh',FlatEdit6.Text);
- if FlatRadioButton1.Checked then myini.WriteString('other','version','cn') else myini.WriteString('other','version','en');
- myini.Destroy;
- console:= '';
- Filedir:= ExtractFileDir(FlatEdit4.Text);
- console:= ' -console';
- if FlatCheckBox1.Checked then console:= console + ' -noforcemaccel';
- if FlatCheckBox2.Checked then console:= console + ' -noforcemparms';
- if FlatCheckBox3.Checked then console:= console + ' -noforcemspd';
- if FlatComboBox1.Text= '32位' then console:= console + ' -32bpp' else console:= console + ' -16bpp';
- console:= console + ' -freq '+FlatEdit6.Text;
- console:= console + ' +connect '+FlatEdit5.Text;
- if FlatRadioButton1.Checked then cstrike:= Filedir + '\cstrike_schinese';
- if FlatRadioButton2.Checked then cstrike:= Filedir + '\cstrike';
- if fileExists(cstrike+'\dingo.cfg') then deleteFile(cstrike+'\dingo.cfg');
- AssignFile(F,cstrike+'\dingo.cfg');
- rewrite(F);
- writeln(F,'name "'+FlatEdit2.Text+'"');
- writeln(F,'setinfo '+FlatEdit1.Text+' '+FlatEdit3.Text);
- closefile(F);
- AssignFile(F,cstrike+'\config.cfg');
- Reset(F);
- tmp:= '';
- while not EOF(F)do
- begin
- Readln(F,S); // 读取一行文本
- tmp:= tmp + S;
- end;
- closefile(F);
- if pos('dingo.cfg',tmp)=0 then
- begin
- //MessageBox(0,pchar(cstrike),'aaa',mb_okcancel);
- AssignFile(F,cstrike+'\config.cfg');
- Append(F);
- writeln(F,'exec dingo.cfg');
- closefile(F);
- end;
- ShellExecute(Handle, 'open', PChar(FlatEdit4.Text), PChar(console), nil, SW_SHOW);
- end;
- procedure TForm1.FlatButton3Click(Sender: TObject);
- begin
- close;
- end;
- procedure TForm1.FormCreate(Sender: TObject);
- var
- myini: Tinifile;
- accel,parms,spd,Physics,refresh,version: string;
- begin
- myini:= Tinifile.Create(ExtractFilePath(Paramstr(0))+'config.ini');
- FlatEdit4.Text:= myini.ReadString('config','cstrike','');
- FlatEdit5.Text:= myini.ReadString('config','serverip','121.101.211.61:27015');
- FlatEdit1.Text:= myini.ReadString('config','amxxpw','');
- FlatEdit2.Text:= myini.ReadString('config','user','');
- FlatEdit3.Text:= myini.ReadString('config','pass','');
- accel:= myini.ReadString('other','accel','1');
- parms:= myini.ReadString('other','parms','1');
- spd:= myini.ReadString('other','spd','0');
- Physics:= myini.ReadString('other','Physics','');
- refresh:= myini.ReadString('other','refresh','75');
- version:= myini.ReadString('other','version','');
- myini.Destroy;
- if pos('1',accel)>0 then FlatCheckBox1.checked:= true else FlatCheckBox1.checked:= false;
- if pos('1',parms)>0 then FlatCheckBox2.checked:= true else FlatCheckBox2.checked:= false;
- if pos('1',spd)>0 then FlatCheckBox3.checked:= true else FlatCheckBox3.checked:= false;
- FlatComboBox1.Text:= Physics;
- FlatEdit6.Text:= refresh;
- if pos('cn',version)>0 then FlatRadioButton1.Checked:= true else FlatRadioButton2.Checked:= true;
- //MessageBox(0,pchar(version),'aaa',mb_okcancel);
- end;
- procedure saveini(co,key,value:string);
- var
- myini: Tinifile;
- begin
- myini:= Tinifile.Create(ExtractFilePath(Paramstr(0))+'config.ini');
- myini.writestring(co,key,value);
- myini.Destroy;
- end;
- end.
复制代码 |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注个册吧
×
|