

Otherwise, it assumes the data represents an arbitrary binary blob. If the secret signal is present, then it assumes that the data represents a binary-formatted serialized CLR object. The answer is that the clipboard puts a secret signal at the start of the binary blob. How do we recognize that it is an arbitrary binary blob, rather than a serialized CLR object? Because if we try to deserialize it as a CLR object, we’ll get garbage. But what about the first master? Suppose the native clipboard has some arbitrary binary blob. Okay, so that keeps the second master happy. When reading an object from the clipboard, takes the binary blob from the clipboard and uses a BinaryFormatter to deserialize the object back into a CLR object. When putting an object on the clipboard, the CLR uses a BinaryFormatter to serialize the object to a binary blob, and puts that binary blob on the clipboard. The second, an object, is the object to put on the clipboard.

The first, a string, is the custom clipboard format name. If a C# program puts a serializable object on the clipboard, then it should be able to read it back as an object. Any format for the data is by mutual agreement of the two parties using that custom format.
Clipboard master chinese windows#
Custom formats on the Windows clipboard are just binary blobs of data with no externally-imposed format. The underlined bytes are the ASCII string Hello, world!, but what’s the other junk? SetData to put text on the clipboard, the actual raw data on the clipboard contains extra stuff.Ĭlipboard.SetData("customText", "Hello, world!") SetData method, you can place data on the clipboard with a custom format name. There are methods for putting text on the clipboard in one of a few the standard text formats. One of the ways of putting data on the clipboard is with the System.
