If it's on a server, could you install a service that checks the files (locally), then reports via http or something like? It could even "watch" the files, and keep the file versions, not needing to check each time...
-----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Robo Sent: Monday, 24 September 2012 6:54 p.m. To: NZ Borland Developers Group - Delphi List Subject: [DUG] Virus scanning causing GetFileVersion to go slow 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: [email protected] Admin: http://delphi.org.nz/mailman/listinfo/delphi Unsubscribe: send an email to [email protected] with Subject: unsubscribe _______________________________________________ NZ Borland Developers Group - Delphi mailing list Post: [email protected] Admin: http://delphi.org.nz/mailman/listinfo/delphi Unsubscribe: send an email to [email protected] with Subject: unsubscribe
