You have a lot of good ideas presented here.
Does it create an empty file to “get a lock” for the name?
nono; I believe that we rely on Windows to ensure that the same temp file name is never given twice on the same computer from the time it boots.
Is there any chance of a collision if there is a split second delay between generating the name and creating the file (if I need to create the file myself).
nono; it will be very bad.
here is the routine I used to get the temporary file.
function GetTemporaryFileName:string;
var
Path, FileName: array[0..MAX_PATH] of Char;
begin
Win32Check(GetTempPath(MAX_PATH, Path) <> 0);
Win32Check(GetTempFileName(Path, '~EX', 0, FileName) <> 0);
Result:=String(Filename);
end;
instead, you can use FileGetTempName () from JclFileUtils.pas in the JCL.
X ray source
share