本文整理自网络,侵删。
//uses ComObj; function compressDB(Afile:string):boolean; // var DaoVar: OLEVariant; begin try DaoVar := CreateOleObject('dao.DBEngine.36'); if FileExists('db.tmp') then deletefile('db.tmp'); // DaoVar.CompactDatabase(afile,'db.tmp'); //压缩无密码的数据库 //压缩有密码的数据库。注意:密码不能为空 DaoVar.CompactDatabase(afile,'db.tmp',';pwd='+SDefDataBasePwd+'',0,';pwd='+SDefDataBasePwd+''); if deletefile(afile) then RenameFile('db.tmp',Afile); result:=true; except result:=False; end; end;
相关阅读 >>
更多相关阅读请进入《Delphi》频道 >>