> 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);
Change this to SetLength(Result,StrLen(Pchar(Result));
this will avoid another memory re-allocation only truncating a piece of
allocated memory...
> if Result[Length(Result)]<>'\' then begin
> SetLength(Result,Length(Result)+1);
> Result[Length(Result)] := '\';
> end;
> end
> else Result := '';
> end;
I really oughta go home - it really has been one of those days...
--
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