I need to sign an .exe file with ..\x64\signtool.exe. However, this obviously does not work while the .exe program is running which assumingly locks the .exe file. So I try to detect whether the .exe file is locked with this function:
function IsExeFileLocked(const AFilename: string): Boolean;
var
F: TFileStream;
begin
try
F:=TFileStream.Create(AFilename, fmOpenRead or fmShareDenyNone);
try
Result:=False;
finally
F.Free;
end;
except
Result:=True;
end;
end;
But this function always gives back False
, even if the .exe program is running!
So how can I detect whether an .exe file is locked by running?