Recent

Author Topic: Possible error in IDE?  (Read 4959 times)

MBulu

  • Guest
Possible error in IDE?
« on: September 22, 2005, 10:07:24 am »
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

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: Possible error in IDE?
« Reply #1 on: October 16, 2005, 09:55:57 pm »
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;

 

TinyPortal © 2005-2018