GetClipboardData (kernel32)
Last changed: -203.110.139.194

.
Summary
TODO - a short description

C# Signature:

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

User-Defined Types:

None.

Alternative Managed API:

Do you know one? Please contribute it!

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 ClipboardDataFormat
/// </summary>
private String GetClipboardData(int ClipboardDataFormat)
{
     if (ClipboardDataFormat != 0)
     {
     OpenClipboard(Handle);

     //Get pointer to clipboard data in the specified format
     IntPtr ClipboardDataPointer = GetClipboardData((uint)ClipboardDataFormat);

     //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);
     CloseClipboard();

     //Convert clipboard data to string
     string ClipboardData = ASCIIEncoding.ASCII.GetString(Buffer);
     return ClipboardData;

     }
     return "";
}

Documentation