Code: Select all
try
LiteConnection.Open;
FEncrypted:=true;
except
on E:Exception do
begin
msg:=E.Message;
//try to open as unencrypted
if (Pos('not a database', msg)>0) or (Pos('image is malformed', msg)>0) then
begin
liteConnection.EncryptionKey:='';
try
LiteConnection.Open;
FEncrypted:=false;
except
on E:Exception do
MessageDlg(E.ClassName + ': ' + E.Message, mtError, [mbOk], 0);
end;
end
else
MessageDlg(E.ClassName + ': ' + E.Message, mtError, [mbOk], 0);
end;
end;
Is this the only way to determine if a .db is encrypted or not? To have to error trap and depend on a matching exception string?