Показать сообщение отдельно
  #10  
Старый 07.03.2012, 09:35
Аватар для NumLock
NumLock NumLock вне форума
Let Me Show You
 
Регистрация: 30.04.2010
Адрес: Северодвинск
Сообщения: 5,426
Версия Delphi: 7, XE5
Репутация: 59586
По умолчанию

вообще-то:

Код:
type
  PLoadFiles = ^TLoadFiles;
  TLoadFiles = record
    Num: Integer;
    NameFile: ShortString;
  end;

var
  AList: TList;    

var
  p: PLoadFiles;
begin
  AList:=TList.Create;
  New(p);
  p^.Num:=0;
  p^.NameFile:='hello';
  AList.Add(p);
  New(p);
  p^.Num:=1;
  p^.NameFile:='world';
  AList.Add(p);
end;

begin
  Dispose(PLoadFiles(AList[1]));
  Dispose(PLoadFiles(AList[0]));
  AList.Free;
end;

begin
  Memo1.Lines.Add(IntToStr(PLoadFiles(AList[0])^.Num));
  Memo1.Lines.Add(PLoadFiles(AList[0])^.NameFile);
  Memo1.Lines.Add(IntToStr(PLoadFiles(AList[1])^.Num));
  Memo1.Lines.Add(PLoadFiles(AList[1])^.NameFile);
end;
ибо PLoadFiles это указатель: PLoadFiles = ^TLoadFiles;
кста, в справке по New это написано:

Цитата:
procedure New(var P: Pointer);

Description

In Delphi code, the New procedure creates a new dynamic variable and sets a pointer variable to point to it. P is a variable of any pointer type. The size of the allocated memory block corresponds to the size of the type that P points to. The newly created variable can be referenced as P^. If there isn't enough memory available to allocate the dynamic variable, an EOutOfMemory exception is raised.

When an application is finished using a dynamic variable created with New, it should dispose of the memory allocated for the variable using the Dispose standard procedure.
там же и пример есть.
__________________
Пишу программы за еду.
__________________
Ответить с цитированием