Autor Beitrag
Tobi482
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 135



BeitragVerfasst: Fr 26.10.07 19:17 
Hi Leute,

bevor ich anfange mein Problem zu erläutern schaut es euch lieber selbst an, sind nur 3 zeilen :)

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
type
     TTest = packed record
          param1         : DWORD;
          param2         : array of WORD;
     end;

procedure TForm1.FormCreate(Sender: TObject);
var
     p   : Pointer;
begin
     p := GetMemory(sizeof(TTest));

     //Crash hier
     Setlength(TTest(p^).param2, 5);

     showmessage(inttostr(TTest(p^).param2[1]));
end;


Warum kann man das dynamische Array nicht dimensionieren?

Mit freundlichen Grüßen
Tobi
Phantom1
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 390



BeitragVerfasst: Fr 26.10.07 19:56 
Versuche es mal so hier:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
type
  PTest = ^TTest;
  TTest = packed record
    param1: DWORD;
    param2: array of WORD;
  end;

procedure TForm1.FormCreate(Sender: TObject);
var
  p: Pointer;
begin
  New(PTest(p));

  Setlength(PTest(p)^.param2, 5);

  showmessage(inttostr(PTest(p)^.param2[1]));

  Dispose(PTest(p));
end;
Tobi482 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 135



BeitragVerfasst: Sa 27.10.07 10:19 
Danke :D

Es klappt nun :)

DAAAAAANNNNNNNKKKKKEEEEE :D

Mit freundlichen Grüßen
Tobi