I am allocating the memory with GetMem (1028 bytes length), so I have an allocated Pointer.
Then I am reading the content and I know that there is e.g. 1028 bytes read. how can I cast pointer, or convert it to a string?
Should I null terminate the content of the memory prior to conversion?
Thanks!
string)? From where the data comes, do you know beforehand that it is string or might there be other type of data as well?0value in there. Why not use code likevar buffer: string; begin SetLength(Buffer, 1028);and then dump the stuff into that string. It will make it much easier to work with. You can access the individual bytes by usingbuffer[20]. For newer versions of Delphi you need to useansistringof course.var buf: AnsiString; SetLength(buf, 1028); read(buf[1]);. Key is to usebuf[1]as the address of the buffer.