No, wrong way. Problem isn't in ProcessMessages(), problem is in running thousands inserts into database. To make this faster use transaction:
zCon.StartTransaction();
query := 'INSERT INTO db_test (file) VALUE ( QuotedStr( 'c:\test.pas' ) )';
for x:= 0 to 20000 do
begin
zCon.ExecuteDirect( query );
end;
zCon.Commit();
Look, I moved query line before for loop, because there is the same value saved in loop 20000 times, what for? There is one enough.