[DUG] Virus scanning causing GetFileVersion to go slow
Alister Christie
alister at salespartner.co.nz
Tue Sep 25 10:11:59 NZST 2012
You could probably put an exclusion in your anti-virus software so that it
does not scan that file at all.
On Mon, Sep 24, 2012 at 6:53 PM, Robo <robo555 at gmail.com> wrote:
> Our program on start up checks for updates on a network drive by
> comparing file version numbers against the local file.
>
> The method runs quick on local files, but slow on the network file,
> especially for files larger than 10MB. We found that disabling virus
> scanning (Microsoft Forefront in this case) means the check is done in
> less than 1sec instead of 10sec.
>
> Anyone know a way to check the version number of a network file
> without triggering the virus scanner? This is particularly problematic
> because this runs every time the program starts, so start up time is
> increasing by heaps.
>
> Here's our code for checking file version:
>
> function TFileVersion.ReadVersionInfo(sProgram: string; Major, Minor,
> Release, Build : pWord) :Boolean;
> var
> Info: PVSFixedFileInfo;
> //{$ifdef VER120} {Delphi 4 definition for this differs from D2 & D3}
> // InfoSize: Cardinal;
> //{$else}
> InfoSize: UINT;
> //{$endif}
> nHwnd: DWORD;
> BufferSize: DWORD;
> Buffer: Pointer;
> begin
> BufferSize := GetFileVersionInfoSize(pchar(sProgram),nHWnd); {Get buffer
> size}
> Result := True;
> if BufferSize <> 0 then begin {if zero, there is no version info}
> GetMem( Buffer, BufferSize); {allocate buffer memory}
> try
> if GetFileVersionInfo(PChar(sProgram),nHWnd,BufferSize,Buffer) then
> begin
> {got version info}
> if VerQueryValue(Buffer, '\', Pointer(Info), InfoSize) then begin
> {got root block version information}
> if Assigned(Major) then begin
> Major^ := HiWord(Info^.dwFileVersionMS); {extract major
> version}
> end;
> if Assigned(Minor) then begin
> Minor^ := LoWord(Info^.dwFileVersionMS); {extract minor
> version}
> end;
> if Assigned(Release) then begin
> Release^ := HiWord(Info^.dwFileVersionLS); {extract release
> version}
> end;
> if Assigned(Build) then begin
> Build^ := LoWord(Info^.dwFileVersionLS); {extract build
> version}
> end;
>
> iDateTime := (Info^.dwFileDateMS) shl 32;
> iDateTime := iDateTime + Info^.dwFileDateLS;
> //always comes back zero for some reason
>
> end else begin
> Result := False; {no root block version info}
> end;
> end else begin
> Result := False; {couldn't extract version info}
> end;
> finally
> FreeMem(Buffer, BufferSize); {release buffer memory}
> end;
> end else begin
> Result := False; {no version info at all in the file}
> end;
> end;
>
> Thanks
>
> Robo
> _______________________________________________
> NZ Borland Developers Group - Delphi mailing list
> Post: delphi at listserver.123.net.nz
> Admin: http://delphi.org.nz/mailman/listinfo/delphi
> Unsubscribe: send an email to delphi-request at listserver.123.net.nz with
> Subject: unsubscribe
>
--
Alister Christie
Computers for People
Ph: 04 471 1849 Fax: 04 471 1266http://www.salespartner.co.nz
Follow us on Twitter http://twitter.com/salespartner
PO Box 13085
Johnsonville
Wellington
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserver.123.net.nz/pipermail/delphi/attachments/20120925/dff7d22a/attachment-0001.html
More information about the Delphi
mailing list