Archive: GetFileTime failing


GetFileTime failing
Hi all, I'm trying to detect when a DLL I'm installing is already installed and identical, so that I don't have to worry about overwriting it when Windows is keeping it open and locked.

GetFileTimeLocal DQSDTools.dll $1 $2
GetFileTime $INSTDIR\DQSDTools.dll $3 $4
IfErrors isdifferent
IntCmpU $1 $3 test3 isdifferent isdifferent
test3:
IntCmpU $2 $4 register isdifferent isdifferent

But GetFileTime fails precisely because the DLL is open and locked!

Is this because GetFileTime needs to be able to get an open handle on the file? Does it seem like NSIS should use FindFirstFile instead?

Dave


A patch
Here's a patch for exec.c that uses FindFirstFile instead of GetFileTime. It seems to work great for me:

#ifdef NSIS_SUPPORT_GETFILETIME
case EW_GETFILETIME:
{
WIN32_FIND_DATA ffd;
HANDLE hfind;
char *highout=g_usrvars[parms[1]];
char *lowout=g_usrvars[parms[2]];
process_string_fromtab(buf,parms[0]);
exec_errorflag++;
*lowout=*highout=0;
hfind=FindFirstFile(buf,&ffd);
if (hfind != INVALID_HANDLE_VALUE)
{
myitoa(lowout,ffd.ftLastWriteTime.dwLowDateTime);
myitoa(highout,ffd.ftLastWriteTime.dwHighDateTime);
exec_errorflag--;
}
CloseHandle(hfind);
}


Cool, I'm going to integrate this with 1.91. It's interesting to note that the old way would work also, if I made it use 0 instead of GENERIC_READ, I think. But this is nice because we can use wildcards.

-Justin