先提供一个字符串加解密的函数:<br>unit Crypt32;<br><br>interface<br><br>const<br> StartKey = 981; <br> MultKey = 12674; <br> AddKey = 35891;<br><br>function Encrypt(const InString:string; StartKey,MultKey,AddKey:Integer): string;<br>function Decrypt(const InString:string; StartKey,MultKey,AddKey:Integer): string;<br><br>implementation<br><br>{function Encrypt(const InString:string; StartKey,MultKey,AddKey:Integer): string;<br>var<br> I : Byte;<br>begin<br> Result := '';<br> for I := 1 to Length(InString) do<br> begin<br> Result := Result + CHAR(Byte(InString) xor (StartKey shr 8));<br> StartKey := (Byte(Result) + StartKey) * MultKey + AddKey;<br> end;<br>end;<br><br>function Decrypt(const InString:string; StartKey,MultKey,AddKey:Integer): string;<br>var<br> I : Byte;<br>begin<br> Result := '';<br> for I := 1 to Length(InString) do<br> begin<br> Result := Result + CHAR(Byte(InString) xor (StartKey shr 8));<br> StartKey := (Byte(InString) + StartKey) * MultKey + AddKey;<br> end;<br>end;<br><br>end.<br>1. 编一个简单的加密程序,把你的 ConnectionString 加密。<br>2. 在你的应用程序中,在 ADOConnection1 的 BeforeConnect 事件中加入:<br><br>procedure TFormMain.ADOConnection1BeforeConnect(Sender: TObject);<br>begin<br> ADOConnection1.ConnectionString:=<br> Decrypt('xxxxxxxxxxxxxxxxxxxxxxxxxxx',StartKey,MultKey,AddKey);<br>end;<br>其中的 xxxxxxxxxxxxxxxxxxxxxxxxxxx 就是你加密后的 ConnectionString