[DUG] Virus scanning causing GetFileVersion to go slow

Paul Heinz paul at accredo.co.nz
Tue Sep 25 08:43:58 NZST 2012


Peter wrote:

> Sadly, I don't think there will be a way (but would be nice to be
proved wrong).

No, as most antivirus systems hook into the file open API within the
windows kernel, there is no way to avoid them, by design. Most opens of
files trigger a signature scan across up of the first 256K of the file
before returning to the caller which both takes quite a bit of time and
wastes a lot of network bandwidth. Some antivirus systems will only scan
potentially executable files (.exe, .dll, etc) , but some scan all files
given the existence of macro viruses and such like.

> You may instead need to put in a saved counter or time check of some
kind so that version-info checks only
> happen occasionally for network drives, e.g. max once per day, or only
every fifth invocation or some such.

> Could you perhaps rely on file datetime as an intervening proxy for
version? Assuming file date checks work 
> more quickly on network drives.

Yes, checking File datetime will be *much* quicker as it can be done by
reading directory entries rather than opening the file itself thus it
doesn't trigger the anti-virus scan. You can then proceed to check the
File version when the datetime indicates it's necessary to avoid false
positives if you want but we don't bother in our code. Being able to
bump the datetime to test the update mechanism is quite handy when
debugging or troubleshooting.

Cheers,
  Paul. 



More information about the Delphi mailing list