You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

111 lines
2.8 KiB
Plaintext

10 months ago
unit u_ini;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, fcButton, fcImgBtn,inifiles, cxControls, cxContainer, cxEdit,
cxTextEdit, DB, DBClient, Buttons;
type
Tfrm_ini = class(TForm)
GroupBox1: TGroupBox;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Edit4: TcxTextEdit;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
procedure fcImageBtn2Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frm_ini: Tfrm_ini;
function ReadPassword(target:string):string;
function WritePassword(source:string):string;
implementation
{$R *.DFM}
function ReadPassword(target:string): string;
var
s:string[20];
i:byte;
s1:string;
begin
{
setlength(s,length(target));
for i:=1 to length(target) do
s[i]:=chr(ord(target[i])-ord('d'));
result:=s;
}
s1:=Copy(Trim(target),7,Length(Trim(target)));
result:=Copy(Trim(s1),1,Length(Trim(s1))-9);
ShowMessage(result);
end;
function WritePassword(source:string): string;
var
t:string[20];
i:byte;
begin
{
setlength(t,length(source));
for i:=1 to length(source) do
t[i]:=chr(ord(source[i])+ord('1'));
result:=t;
}
result:='ds.com'+trim(source)+'20040201';
ShowMessage(result);
end;
procedure Tfrm_ini.fcImageBtn2Click(Sender: TObject);
begin
application.Terminate;
end;
procedure Tfrm_ini.FormShow(Sender: TObject);
var
inifile1:Tinifile;
psw:string;
begin
inifile1:=Tinifile.Create(ExtractFilePath(application.ExeName)+'main.ini');
psw:=inifile1.ReadString('database','Password','');
psw:=ReadPassword(psw);
edit4.text:=copy(inifile1.ReadString('database','Password',''),0,length(inifile1.ReadString('database','Password',''))-1);
edit3.text:=copy(inifile1.ReadString('database','User ID',''),0,length(inifile1.ReadString('database','User ID',''))-1);
edit2.text:=copy(inifile1.ReadString('database','Initial Catalog',''),0,length(inifile1.ReadString('database','Initial Catalog',''))-1);
edit1.text:=copy(inifile1.ReadString('database','Data Source',''),0,length(inifile1.ReadString('database','Data Source',''))-1);
end;
procedure Tfrm_ini.BitBtn1Click(Sender: TObject);
var
inifile1:Tinifile;
psw:string;
begin
inifile1:=Tinifile.Create(ExtractFilePath(application.ExeName)+'main.ini');
inifile1.WriteString('database','Password',WritePassword(edit4.text)+';');
inifile1.WriteString('database','User ID',edit3.text+';');
inifile1.WriteString('database','Initial Catalog',edit2.text+';');
inifile1.WriteString('database','Data Source',edit1.text+';');
end;
end.