Jump to content
Rafael Dipold

Issue in copy and past

Recommended Posts

 

Hi,

Can anyone explain to me why this specific sequence of characters, when copying to clipboard and pasting to notepad, windows pastes memory garbage?

 

If I change '42' to '32', for example, this issue not happen

procedure TForm1.Button1Click(Sender: TObject);
var
  C, R: TArray<String>;
begin
  C := [];
  C := C + ['42'];
  C := C + ['N'];
  C := C + ['N'];
  C := C + ['=DOLLAR(4967.32, 2)'];
  C := C + ['=DOLLAR(1515.61, 2)'];
  C := C + ['=DOLLAR(0, 2)'];
  C := C + ['=DOLLAR(58054.89, 2)'];
  C := C + ['=DOLLAR(4084.55, 2)'];

  R := R + [''.Join(#9, C)];

  Clipboard.AsText := ''.Join(#13#10, R);

  ShowMessage('Copy to Clipboard!');
end;

 

Share this post


Link to post
10 minutes ago, Rafael Dipold said:

when copying to clipboard and pasting to notepad, windows pastes memory garbage?

What does that garbage look like?

Share this post


Link to post

I get:


42    N    N    =DOLLAR(4967.32, 2)    =DOLLAR(1515.61, 2)    =DOLLAR(0, 2)    =DOLLAR(58054.89, 2)    =DOLLAR(4084.55, 2)

 

I cannot spot the garbage.

Share this post


Link to post
42    N    N    =DOLLAR(4967.32, 2)    =DOLLAR(1515.61, 2)    =DOLLAR(0, 2)    =DOLLAR(58054.89, 2)    =DOLLAR(4084.55, 2)
42    N    N    =DOLLAR(4B8r3B4p7yhRXuBWLqsQ546WR43cqQwrbXMDFnBi6vSJBeif8tPW85a7r7DM961Jvk4hdryZoByEp8GC8HzsqJpRN4FxGM9, 2)

For me, even if I copy and paste here on the Forum, it pastes garbage from memory... see second line above.


I will try to install the latest windows updates.. seems to be a windows bug

Share this post


Link to post

I would start by examining what it is you put onto the clipboard. You can use a simple clipboard viewer for this but it needs to be able to display the data as hex to be of much use.

The Drag and Drop Component Suite has a Drop Source Analyzer application that can do it. If you're brave you can use the one I have attached.

image.thumb.png.317c337e06be58904cbc19da863e7a87.png

SourceAnalyzer.zip

Share this post


Link to post

I updated Windows to 22H2, no programs running in the background, and even copying this string from notepad, my string has only memory garbage..

 

Initially I thought it was a bug in Delphi, that's why I posted it here, but now I see that my computer has some glitch, as I tested it on another computer and the bug doesn't happen

 

image.thumb.png.3b0a2e9a4871c1597b342a2eff2cb2d0.png

Share this post


Link to post
22 minutes ago, Rafael Dipold said:

no programs running in the background

You might not have started anything manually but there are always programs running in the background. This isn't DOS after all.

I would suggest you run a virus scanner on that system ASAP. My guess is that "something" has hooked into the clipboard chain and is corrupting the clipboard.

 

If the list contains CF_UNICODETEXT then it should also contain CF_TEXT because the clipboard internally synthesizes between the two formats automatically. It is impossible to only have one of them on the clipboard.

Share this post


Link to post

In fact there was a trojan installed, it must have been a few days ago when I tried to install software downloaded via torrent

 

Thank you, problem solved

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×