Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2006 Oct : GetEnvironmentVariable Error

www.cryer.info
Managed Newsgroup Archive

GetEnvironmentVariable Error

Subject:GetEnvironmentVariable Error
Posted by:"Marcio Ehrlich" (marcioehrlich_at_ig.com.br)
Date:Sun, 1 Oct 2006 19:16:48

This routine used to compile with D5 but is raising "Ambiguous Overloaded
Call to GetEnvironmentVariable" now with D7.
What have changed?

function GetTempFolder : string;
var
  BufSize: Integer;  // buffer size required for value
begin
  // Get required buffer size (inc. terminal #0)
  BufSize := GetEnvironmentVariable(PChar('TEMP'), nil, 0);
  if BufSize > 0 then
  begin
    // Read env var value into result string
    SetLength(Result, BufSize - 1);
    GetEnvironmentVariable(PChar('TEMP'),
      PChar(Result), BufSize);
  end
  else
    // No such environment variable
    Result := '';
end;

Thanks,
Marcio Ehrlich

Replies:

www.cryer.info
Managed Newsgroup Archive