📄 getsetall.pas
字号:
unit GetSetAll;
interface
uses
Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls,
Buttons, dmHPFUnit, Dialogs, Messages, Variants, ExtCtrls,
INIFiles, CryptoModule;
procedure GetCompanyName(var CompanyName : String);
procedure SetCompanyName(CompanyName : String);
procedure GetUser(var User : String);
procedure SetUser(User : String);
procedure GetConnectionString(var ConnectionString : WideString);
procedure SetConnectionString(ServerName : String);
procedure GetFirstConf(var FirstConf : String);
procedure SetFirstConf(FirstConf : String);
procedure GetRecipient(var toRecipients : TStrings);
procedure setRecipient(toRecipients : TStrings);
function GetExpiryDate : String;
procedure setExpiryDate(expiryDate : String);
procedure getDepartment(var Department : String);
procedure setDepartment(Department : String);
var
ini : TIniFile;
sEncrypted, sDecrypted : AnsiString;
const
myKey = 55142;
implementation
uses DateUtils;
procedure GetCompanyName(var CompanyName : String);
begin
Ini := TIniFile.Create(ChangeFileExt(Application.ExeName,'.ini'));
try
CompanyName := ini.ReadString('MaintainMe','GBC001','');
finally
ini.Free;
end;
sDecrypted := Decrypt(CompanyName,myKey);
CompanyName := sDecrypted;
end;
procedure SetCompanyName(CompanyName : String);
begin
sEncrypted := Encrypt(CompanyName, myKey);
CompanyName := sEncrypted;
Ini := TIniFile.Create(ChangeFileExt(Application.ExeName,'.ini'));
try
ini.WriteString('MaintainMe','GBC001',CompanyName);
finally
ini.Free;
end;
end;
procedure GetUser(var User : String);
begin
Ini := TIniFile.Create(ChangeFileExt(Application.ExeName,'.ini'));
try
User := ini.ReadString('MaintainMe','GBC002','');
finally
ini.Free;
end;
sDecrypted := Decrypt(User,myKey);
User := sDecrypted;
end;
procedure SetUser(User : String);
begin
sEncrypted := Encrypt(User,myKey);
User := sEncrypted;
Ini := TIniFile.Create(ChangeFileExt(Application.ExeName,'.ini'));
try
ini.WriteString('MaintainMe','GBC002',User);
finally
ini.Free;
end;
end;
procedure GetConnectionString(var ConnectionString : WideString);
begin
Ini := TIniFile.Create(ChangeFileExt(Application.ExeName,'.ini'));
try
ConnectionString := ini.ReadString('MaintainMe','GBC003','');
finally
ini.Free;
end;
sDecrypted := Decrypt(ConnectionString,myKey);
ConnectionString := sDecrypted;
end;
procedure SetConnectionString(ServerName : String);
var ConnectionString : WideString;
begin
ConnectionString := 'Provider=SQLOLEDB.1;Persist Security Info=True;' +
'Password=Gawie123;User ID=HPF_SQL_LOGIN;Data Source=' +
ServerName + '\SQLEXPRESS;Initial Catalog=HPF-GROUP;' +
'Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;' +
'Use Encryption for Data=False;Tag with column collation when possible=False';
sEncrypted := Encrypt(ConnectionString,myKey);
ConnectionString := sEncrypted;
Ini := TIniFile.Create(ChangeFileExt(Application.ExeName,'.ini'));
try
ini.WriteString('MaintainMe','GBC003',ConnectionString);
finally
ini.Free;
end;
end;
procedure GetFirstConf(var FirstConf : String);
begin
Ini := TIniFile.Create(ChangeFileExt(Application.ExeName,'.ini'));
try
FirstConf := ini.ReadString('MaintainMe','GBC004','');
finally
ini.Free;
end;
sDecrypted := Decrypt(FirstConf,myKey);
FirstConf := sDecrypted;
end;
procedure SetFirstConf(FirstConf : String);
begin
sEncrypted := Encrypt(FirstConf,myKey);
FirstConf := sEncrypted;
Ini := TIniFile.Create(ChangeFileExt(Application.ExeName,'.ini'));
try
ini.WriteString('MaintainMe','GBC004',FirstConf);
finally
ini.Free;
end;
end;
procedure GetRecipient(var toRecipients : TStrings);
var Recipient : String;
I : Integer;
Text : String;
begin
Ini := TIniFile.Create(ChangeFileExt(Application.ExeName,'.ini'));
try
Recipient := ini.ReadString('MaintainMe','GBC005','');
finally
ini.Free;
end;
sDecrypted := Decrypt(Recipient,myKey);
Recipient := sDecrypted;
Text := '';
toRecipients := TStringList.Create;
for I := 1 to Length(Recipient) do
begin
if Recipient[i] <> ':'
then
Text := Text + Recipient[I]
else
begin
toRecipients.Add(Text);
Text := '';
end;
end;
end;
procedure SetRecipient(toRecipients : TStrings);
var Recipients : String;
I : Integer;
begin
Recipients := '';
for I := 0 to toRecipients.Count - 1 do
begin
Recipients := Recipients + toRecipients[I] + ':';
end;
sEncrypted := Encrypt(Recipients,myKey);
Recipients := sEncrypted;
Ini := TIniFile.Create(ChangeFileExt(Application.ExeName,'.ini'));
try
ini.WriteString('MaintainMe','GBC005',Recipients);
finally
ini.Free;
end;
end;
function GetExpiryDate : String;
var ExpiryDate : String;
begin
Ini := TIniFile.Create(ChangeFileExt(Application.ExeName,'.ini'));
try
ExpiryDate := ini.ReadString('MaintainMe','GBC006','');
finally
ini.Free;
end;
sDecrypted := Decrypt(ExpiryDate,myKey);
Result := sDecrypted;
end;
procedure setExpiryDate(expiryDate : String);
begin
sEncrypted := Encrypt(expiryDate,myKey);
expiryDate := sEncrypted;
Ini := TIniFile.Create(ChangeFileExt(Application.ExeName,'.ini'));
try
ini.WriteString('MaintainMe','GBC006',expiryDate);
finally
ini.Free;
end;
end;
procedure getDepartment(var Department : String);
begin
Ini := TIniFile.Create(ChangeFileExt(Application.ExeName,'.ini'));
try
Department := ini.ReadString('MaintainMe','GBC007','');
finally
ini.Free;
end;
sDecrypted := Decrypt(Department,myKey);
Department := sDecrypted;
end;
procedure setDepartment(Department : String);
begin
sEncrypted := Encrypt(Department,myKey);
Department := sEncrypted;
Ini := TIniFile.Create(ChangeFileExt(Application.ExeName,'.ini'));
try
ini.WriteString('MaintainMe','GBC007',Department);
finally
ini.Free;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -