Possible error in IDE? lazarus / 9-Editor ---------------------------------------------------------------------- MBulu · 2005-09-22 08:07 Sorry for my English, some function, for example "GetTempPath" or "GetEnvironmentVariable", if used from IDE works only the first time. If i run program more than one time from IDE, they returns bad value, but if i  run the compiled program they work correctly. For example: *********************************   function WinTemp:string;   Var AppoPChar:Pchar;   begin     getmem (AppoPChar, MAX_PATH);     GetTempPath (MAX_PATH, AppoPChar);     Result:=AppoPChar;     FreeMem (AppoPChar, MAX_PATH);   end; ********************************* Appo:=WinTemp; The first time the value of Appo is 'C:\Documents and Settings\BONMAR\Impostazioni locali\Temp\' After first time the value of Appo is 'C:\WINDOWS\' It's a bug? ---------------------------------------------------------------------- felipemdc · 2005-10-16 19:55 Works perfectly here. Also you forgot to type cast. If you are using a beta lazarus you should get a new stable release like 0.9.10 Here is my perfectly working code running from a button OnClick on lazarus 0.9.10 stable: procedure TjanelaPrincipal.Button1Click(Sender: TObject); var   AppoPChar:Pchar; begin   getmem (AppoPChar, MAX_PATH);   GetTempPath (MAX_PATH, AppoPChar);   Caption := string(AppoPChar);   FreeMem (AppoPChar, MAX_PATH); end;