Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!
Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.
Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!
[Solved] Lazarus Pascal / Delphi - How to Copy a TMemoryStream into a String
Delphi, Lazarus, Free Pascal
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2869
Topic starter
February 11, 2021 9:02 AM
A quick trick, showing you how to copy the content of a TMemoryStream into a string:
function MemoryStreamToString(aMemoryStream: TMemoryStream): AnsiString;
begin
SetString(Result, PAnsiChar(aMemoryStream.Memory), aMemoryStream.Size);
end;
(@Anonymous)
Joined: 1 second ago
Posts: 0
March 27, 2025 4:32 AM
Hello.
How to copy from TMemoryStream to Clipboard as string ?
Thanks!
This post was modified 3 months ago by
Anonymous
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2869
Topic starter
March 28, 2025 2:22 AM
Hi Shonty,
I'm not the most experienced TMemoryStream user, but it sounds like this example could be helpful.
It seems to show to copy the content of a TMemoryStream as a TStringList to a TMemo.
The TStringList.text then can be copied to the clipboard with (obviously,
var
List : TStringList;
...
Clipboard.AsText := List.Text; (TStringList)
...
Hope this is helpful.
(@Anonymous)
Joined: 1 second ago
Posts: 0
March 28, 2025 2:37 AM
Yes, thanks. I didn't get any results with TMemoryStream either.
I replaced it with TStringStream.
Thanks.