setclipboarddata (user32)
Last changed: -175.142.245.97

.

C# Signature:

[DllImport("user32.dll")]
static extern IntPtr SetClipboardData(uint uFormat, IntPtr hMem);

Code Sample

string nullTerminatedStr = "helloworld" + "\0";
byte[] strBytes = Encoding.Unicode.GetBytes(nullTerminatedStr);
IntPtr hglobal = Marshal.AllocHGlobal(strBytes.Length);
Marshal.Copy(strBytes, 0, hglobal, strBytes.Length);
OpenClipboard(IntPtr.Zero);
EmptyClipboard();
SetClipboardData(CF_UNICODETEXT, hglobal);
CloseClipboard();
Marshal.FreeHGlobal(hglobal);