📄 maindata.pas
字号:
unit MainData;
interface
uses forms,Windows,
SysUtils, Classes, DB, ADODB;
type
TdmMainData = class(TDataModule)
ADOConnection1: TADOConnection;
qryFormStorage: TADOQuery;
qryFormStorageFormClass: TStringField;
qryFormStorageFormStorage: TBlobField;
adcExecSQL: TADOConnection;
qryS_SysLog: TADOCommand;
procedure ADOConnection1BeforeConnect(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
function LoadDbInfo() :string;
procedure SaveDbInfo();
function ExecSqlText(SqlText:TStrings; SqlCmdTimeOut:integer) :Boolean;
procedure AddSysLog(tsNote: string);
end;
function EncryptStr(tsDecrypt:string) :string;
function DecryptStr(tsEncrypt:string) :string;
procedure DeleteDbInfoFile();
var
dmMainData: TdmMainData;
implementation
uses Main, SelfFunc, Splash;
{$R *.dfm}
function EncryptStr(tsDecrypt:string) :string;
const AsciiA :integer =65;
var n,i,tn :integer;
tc1,tc2 :char;
tsRet :string;
begin
n :=Length(tsDecrypt);
tsRet :='';
for i :=1 to n do
begin
tn :=Ord(tsDecrypt[i]);
tc1 :=Chr(tn div 26 +AsciiA);
tc2 :=Chr(tn mod 26 +AsciiA);
tsRet :=tsRet +tc1 +tc2;
end;
Result :=tsRet;
end;
function DecryptStr(tsEncrypt:string) :string;
const AsciiA :integer =65;
var n,i,tn :integer;
tc1,tc2 :char;
tsRet :string;
begin
Result :='';
n :=Length(tsEncrypt) -2;
if n =0 then Exit;
if (n mod 2) >0 then Exit;
tsRet :='';
for i :=1 to (n div 2) do
begin
tc1 :=tsEncrypt[i*2-1];
tc2 :=tsEncrypt[i*2];
tn :=(Ord(tc1)-AsciiA)*26 +(Ord(tc2)-AsciiA);
if (tn <0) or (tn >255) then
begin
msgbox(inttostr(i) +' '+tc1+tc2+' '+ inttostr(tn));
Exit;
end;
tsRet :=tsRet +Chr(tn);
end;
Result :=tsRet;
end;
procedure DeleteDbInfoFile();
var tsDbFile :string;
begin
tsDbFile :=Application.ExeName;
tsDbFile :=Copy(tsDbFile, 1, Length(tsDbFile)-4) +'.ini';
if FileExists(tsDbFile) then DeleteFile(tsDbFile);
end;
function TdmMainData.LoadDbInfo() :string;
var tsText :TStrings;
tsDbFile :string;
begin
tsDbFile :=Application.ExeName;
tsDbFile :=Copy(tsDbFile, 1, Length(tsDbFile)-4) +'.ini';
Result :='';
if not FileExists(tsDbFile) then Exit;
tsText :=TStringList.Create;
try
try
tsText.LoadFromFile(tsDbFile);
Result :=DecryptStr(tsText.Text);
finally
tsText.Free;
end;
except
MsgBoxErr('礚猭ゴ邵计誹畐皌竚ゅン<' +tsDbFile+ '>');
end;
end;
procedure TdmMainData.SaveDbInfo();
var tsText :TStrings;
tsDbFile,ts :string;
begin
if LoadDbInfo() <>'' then Exit;
tsDbFile :=Application.ExeName;
tsDbFile :=Copy(tsDbFile, 1, Length(tsDbFile)-4) +'.ini';
tsText :=TStringList.Create;
try
try
ts :=dmMainData.ADOConnection1.ConnectionString;
tsText.Text :=EncryptStr(ts);
tsText.SaveToFile(tsDbFile);
finally
tsText.Free;
end;
except
MsgBoxErr('礚猭玂
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -