getclipboarddata (user32)
Last changed: logicchild-148.111.243.16

.
Summary

C# Signature:

[DllImport("user32.dll")]
static extern IntPtr GetClipboardData(uint uFormat);

User-Defined Types:

None.

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

[DllImport("user32.dll")]
static extern IntPtr GetClipboardData(uint uFormat);

/// <summary>
/// Gets the data on the clipboard in the format specified by the selected item of the specified listbox.
/// </summary>
private byte[] GetClipboardData(ListBox ListBox)
{
     uint SelectedFormat = GetSelectedClipboardFormat(ListBox);
     if (SelectedFormat != 0)
     {
     OpenClipboard(Handle);

     //Get pointer to clipboard data in the selected format
     IntPtr ClipboardDataPointer = GetClipboardData(SelectedFormat);

     //Do a bunch of crap necessary to copy the data from the memory
     //the above pointer points at to a place we can access it.
     UIntPtr Length = GlobalSize(ClipboardDataPointer);
     IntPtr gLock = GlobalLock(ClipboardDataPointer);

     //Init a buffer which will contain the clipboard data
     byte[] Buffer = new byte[(int)Length];

     //Copy clipboard data to buffer
     Marshal.Copy(gLock, Buffer, 0, (int)Length);

     GlobalUnlock(gLock); //unlock gLock

     CloseClipboard();

     return Buffer;
     }

     return new byte[] {};
}

Alternative Managed API:

Do you know one? Please contribute it!

Documentation