>> There must be an API call which returns de path to the Windows Temp
>> directory (e.g "c:\Temp" on WinNT and "c:\Windows\Temp" on Win95/98).
>> Does anyone know which is it (or could/should be)?
> Yea, gotta handle on that one; I use it for my freeware software to clear
> out the temporary directory of junk on startup HEREYAGO:
> function TAnybodiesForm.GetTheTempDIR: string;
> var Tmp: array[0..255] of char;
> Ret: string;
> begin
> if GetTempPath(255, Tmp) <> 0 then begin
> Ret := StrPas(Tmp);
> if Ret[length(Ret)] = '\' then Ret := copy(Ret, 1, length(Ret) - 1);
> result := string(Ret) + '\';
> end
> else begin
> Result := '';
> end;
> end;
How about a version that doesn't reallocate the string-space so many times.
(same effect and side-effects (other than resource usage), just tidier I hope)...
function GetTempDir:String;
const
MaxPathLength = 255;
begin
SetLength(Result,MaxPathLength+1);
if GetTempPath(MaxPathLength,PChar(Result))<>0 then begin
Result := StrPas(Result);
if Result[Length(Result)]<>'\' then begin
SetLength(Result,Length(Result)+1);
Result[Length(Result)] := '\';
end;
end
else Result := '';
end;
...Many apologies for the pickiness... it's one of those days 8-(
--
Aaron Scott-Boddendijk
Jump Productions
(07) 838-3371 Voice
(07) 838-3372 Fax
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz