W
W1979
Unregistered / Unconfirmed
GUEST, unregistred user!
我們用TDatabase時﹐里面要寫帳號和密碼﹐所以我想把它們放到一個DLL中﹐
Export出兩個函數比如GetUser,GetPassword,但是這也有問題﹐別人拿到這
個DLL只要一show就看的到用戶和密碼,加密的方法不行﹐因為我防的是自己
人.所以我寫了一個控件﹕
unit tech;
interface
uses
Windows, SysUtils, Graphics, Classes, Controls, Db, DBCommon,
Bde, SMIntf,DBTables;
type
TDatabase1 = class(TDatabase)
private
FInternalParams: TStrings;
protected
procedure DoConnect; override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
end;
procedure Register;
implementation
constructor TDatabase1.Create(AOwner: TComponent);
begin
inherited;
FInternalParams := TStringList.Create;
FInternalParams.Add('SERVER NAME=pbcost');
FInternalParams.Add('USER NAME=tech');
FInternalParams.Add('NET PROTOCOL=TNS');
FInternalParams.Add('OPEN MODE=READ/WRITE');
FInternalParams.Add('SCHEMA CACHE SIZE=8');
FInternalParams.Add('LANGDRIVER=');
FInternalParams.Add('SQLQRYMODE=');
FInternalParams.Add('SQLPASSTHRU MODE=SHARED AUTOCOMMIT');
FInternalParams.Add('SCHEMA CACHE TIME=-1');
FInternalParams.Add('MAX ROWS=-1');
FInternalParams.Add('BATCH COUNT=200');
FInternalParams.Add('ENABLE SCHEMA CACHE=FALSE');
FInternalParams.Add('SCHEMA CACHE DIR=');
FInternalParams.Add('ENABLE BCD=FALSE');
FInternalParams.Add('ENABLE INTEGERS=FALSE');
FInternalParams.Add('LIST SYNONYMS=NONE');
FInternalParams.Add('ROWSET SIZE=20');
FInternalParams.Add('BLOBS TO CACHE=64');
FInternalParams.Add('BLOB SIZE=32');
FInternalParams.Add('OBJECT MODE=TRUE');
FInternalParams.Add('PASSWORD=y2tech');
end;
destructor TDatabase1.Destroy;
begin
FInternalParams.Free;
inherited;
end;
procedure TDatabase1.DoConnect;////////////////////////////////HERE[?]
begin
if not(csDesigning in ComponentState)then
begin
try
Params.Assign(FInternalParams);
inherited;
finally
// Params.clear;//[?] 這樣出錯
end;
end
end;
procedure Register;
begin
RegisterComponents('Samples', [TDatabase1]);
end;
end.
原來是想DoConnect后立即把參數清掉﹐不料這樣會出錯﹐只好判斷是否在
運行狀態﹐運行時才給參數賦值﹐這樣也有問題﹐因為運行時人家只要一show
就知道我的密碼,請問怎么辦呢
Export出兩個函數比如GetUser,GetPassword,但是這也有問題﹐別人拿到這
個DLL只要一show就看的到用戶和密碼,加密的方法不行﹐因為我防的是自己
人.所以我寫了一個控件﹕
unit tech;
interface
uses
Windows, SysUtils, Graphics, Classes, Controls, Db, DBCommon,
Bde, SMIntf,DBTables;
type
TDatabase1 = class(TDatabase)
private
FInternalParams: TStrings;
protected
procedure DoConnect; override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
end;
procedure Register;
implementation
constructor TDatabase1.Create(AOwner: TComponent);
begin
inherited;
FInternalParams := TStringList.Create;
FInternalParams.Add('SERVER NAME=pbcost');
FInternalParams.Add('USER NAME=tech');
FInternalParams.Add('NET PROTOCOL=TNS');
FInternalParams.Add('OPEN MODE=READ/WRITE');
FInternalParams.Add('SCHEMA CACHE SIZE=8');
FInternalParams.Add('LANGDRIVER=');
FInternalParams.Add('SQLQRYMODE=');
FInternalParams.Add('SQLPASSTHRU MODE=SHARED AUTOCOMMIT');
FInternalParams.Add('SCHEMA CACHE TIME=-1');
FInternalParams.Add('MAX ROWS=-1');
FInternalParams.Add('BATCH COUNT=200');
FInternalParams.Add('ENABLE SCHEMA CACHE=FALSE');
FInternalParams.Add('SCHEMA CACHE DIR=');
FInternalParams.Add('ENABLE BCD=FALSE');
FInternalParams.Add('ENABLE INTEGERS=FALSE');
FInternalParams.Add('LIST SYNONYMS=NONE');
FInternalParams.Add('ROWSET SIZE=20');
FInternalParams.Add('BLOBS TO CACHE=64');
FInternalParams.Add('BLOB SIZE=32');
FInternalParams.Add('OBJECT MODE=TRUE');
FInternalParams.Add('PASSWORD=y2tech');
end;
destructor TDatabase1.Destroy;
begin
FInternalParams.Free;
inherited;
end;
procedure TDatabase1.DoConnect;////////////////////////////////HERE[?]
begin
if not(csDesigning in ComponentState)then
begin
try
Params.Assign(FInternalParams);
inherited;
finally
// Params.clear;//[?] 這樣出錯
end;
end
end;
procedure Register;
begin
RegisterComponents('Samples', [TDatabase1]);
end;
end.
原來是想DoConnect后立即把參數清掉﹐不料這樣會出錯﹐只好判斷是否在
運行狀態﹐運行時才給參數賦值﹐這樣也有問題﹐因為運行時人家只要一show
就知道我的密碼,請問怎么辦呢