在Delphi程序运行中 改变已设定密码的数据库文件的密码
interface
uses bde;
procedure _AddNewPassword(dbname:string;Password:String='700203');
const
RESTRUCTURE_TRUE = WordBool(1);
var
TblDesc: CRTblDesc;
hDb: hDBIDb;
temptable:ttable;
begin
temptable:=Ttable.Create(application);
temptable.DatabaseName:='DBDEMOS';
temptable.TableType:=ttParadox;
temptable.TableName:=dbname;
temptable.Exclusive:=true;
temptable.open;
FillChar(TblDesc,SizeOf(CRTblDesc),0);
with TblDesc do
begin
StrPCopy(szTblName, temptable.tableName);
StrCopy(szTblType, szPARADOX);
StrPCopy(szPassword, Password);
bProtected := RESTRUCTURE_TRUE;
end;
Check(DbiGetObjFromObj(hDBIObj(temptable.Handle), objDATABASE, hDBIObj(hDb)));
temptable.Close;
temptable.free;
Check(DbiDoRestructure(hDb, 1, @TblDesc, nil, nil, nil, FALSE));
Session.AddPassword(Password);
end;