Re: Pointers in delphi



qnewpq wrote:

am doing an application in biometric. I am allocating a pointer and the
size needed to store the image data. then i need to copy data from another
variable to this pointer.

{
ImgDetail is widestring.
myImage is untyped pointer.
}
1. ImgDetail:='}↓§ruiyweurywuyrfwiuhasicasid etc';
2. Reallomem(myImage,2356);
3. myImage:=@ImgDetail;

when i do the above my sensor driver is giving me an error. I have tested
all the options and found out its line 3 which is not ok! how can I copy
the image details to the space allocated in the pointer? so that I dont
point myimage to ImaDetail teh way am doing? The image details is in
ascii.


Please help!

WideString is already a pointer that looks at the data.
you can pass the ImgDetail directly where as a pointer using a
case.
from looking at your code, i think all you want to do is perform a
copy.
CopyMemory(MyImage, Pointer(ImgDetail), 2356); or , the size could be the Length(ImgDetail)*2 etc...


 if your trying only to set a generic pointer from a non generic type
then you could try this
MyImage := Pointer(imgDetail);
 but care must be taken here, when changing the contents of imgDetail
in the standard way of strings, the string pointer most likely will change.

.



Relevant Pages

  • Re: Pointers in delphi
    ... your third line is an attempt to copy the address of a pointer (ImgDetail) ... to a pointer, because strings in Delphi are already pointers. ... your reference to the allocated memory. ... I am allocating a pointer and the ...
    (alt.comp.lang.borland-delphi)
  • RE: error: saving to a ntext column becomes corrupted (???)
    ... when ntext, text and image data values are larger than 8k they are stored outside the data page for the row via a pointer. ... see sql books on line for more info under managing ntext, text, and image data ...
    (microsoft.public.sqlserver.programming)