• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 945
  • Last Modified:

Pointers in Delphi 32

My problem is, I have to increment a pointer.
    In old 16 bit code, I does it by use
   p := ptr(seg(p^),ofs(p^) + n);
    but this is not longer possible in delphi 32. So how can I do the
same stuff in 32bit?
    Here is some dummy code to make my problem more understandable...
    Type
   Rec = record
      size: integer;
      data: array[0..0] of byte;
   end;
   prec = ^rec;
   procedure readmorerecs;
   var
  p : pointer;
  numberofrec: integer;
   begin
  filestream := tfilestream.create('somefile',fmopenread);
  getmem(p,filestream.size);
  filestream.read(numberofrec,sizeof(integer));
  filestream.read(p^,filestream.size);
  interpretrec(p,numberofrec);
  filestream.free;
   end;
   procedure interpretrecs(var p; numberofrec: integer);
   var
  myrec: prec;
   begin
  myrec := @p;
  while numberofrec > 0 do
  with myrec^ do
  begin
   dosomething with myrec
   // not possible in 32 bit
   myrec := Ptr(Seg(myrec^),Ofs(myrec^)+Size);
   dec(numberofrec);
  end;
   end; *)

--
info@cpfreiburg.de
0
karlhfreiburg
Asked:
karlhfreiburg
1 Solution
 
hustchCommented:
In Delphi 32, you don't use the segment any more, the 32-bit pointer is an offset.
You can add Size to your pointer directly. If the Compiler won't let you do it with a pointer of type prec, you can typecast it to type PChar (myrec := prec(PChar(myrec)+size);)
0
 
julio011597Commented:
Maybe Size here is meant to be SizeOf(Rec)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now