The method of compressing the Access (*. Mdb) database is implemented.
The following functions are used to compress the Access database. You need to add COMOBJ unit Function CompactDatabase (AFILENAME, APASSWORD: STRING): Boolean; // Compressed & Repair Database, Coverage Source File const sconnectionstring = 'provider = microsoft.jet.OleDb.4.0; Data Source =% S; ' ' Jet OLEDB: Database Password =% s; '; var spath, sfile: array [0..254] of char; steppFileName: String; JE: Olevariant; Begin GetTemppath (40, spath); / / Get Windows Temp Path GetTempFileName (Spath, '~ CP', 0, SFile); // Take the TEMP file name, Windows will automatically create 0 byte files StempFileName: = sfile; // pchar-> string deletefile (STEMPFILENAME) ; // Delete 0 byte files established by Windows Try JE: = CREATEOLOBJECT ('JRO.jetengine'); // Establish an OLE object, the function ends OLE object exceeds the scope automatically release olecheck (Je.CompactDatabase (Format (Sconnectionstring, [ AfileName, APASSWORD]), FORMAT (SCONNECTIONSTRING, [STEMPFILENAME, APASSWORD])))))))))); // Compress database // copy and overwrite the source database file, if the copy fails, the function returns a false, compressed, but does not meet the function of the function, RESULT: = CopyFile (STEMPFILENAME), PCHAR (AFILENAME), FALSE); deletefile (STEMPFILENAME); // Delete Temporary File Except Result: = false; // Compression Failure End; End;