Desktop Functions:

   Smart Device Functions:

Show Recent Changes
Subscribe (RSS)
Misc. Pages
Helpful Tools
Suggested Reading
Website TODO List
Support Forum
Download Visual Studio Add-In

Terms of Use
Privacy Policy
SetClipboardData (coredll)

coredll is for smart devices, not desktop Windows. Therefore, this information only applies to code using the .NET Compact Framework. To see if information for SetClipboardData in other DLLs exists, click on Find References to the right.

Set Clipboad data(Text, bitmap, etc).
OpenClipboard(), CloseClipboard(), EmptyClipboard()

C# Signature:

[DllImport("Coredll.dll", SetLastError=true)]
static extern int SetClipboardData(int uFormat, IntPtr hMem);

VB Signature:

VB.Net Signature:

<DllImport("coredll.dll")> Shared Function SetClipboardData(ByVal uFormat As Integer, ByVal hMem As IntPtr) As Integer
End Function

User-Defined Types:


Alternative Managed API:

Do you know one? Please contribute it!



Tips & Tricks:

Please add some!

Sample Code:

    <DllImport("coredll.dll")> Shared Function OpenClipboard(ByVal hWndNewOwner As Integer) As Boolean
    End Function
    <DllImport("coredll.dll")> Shared Function CloseClipboard() As Boolean
    End Function
    <DllImport("coredll.dll")> Shared Function EmptyClipboard() As Boolean
    End Function
    <DllImport("coredll.dll")> Shared Function SetClipboardData(ByVal uFormat As Integer, ByVal hMem As IntPtr) As Integer
    End Function

    Enum uFormat
        CF_TEXT = 1
        CF_BITMAP = 2
        CF_SYLK = 4
        CF_DIF = 5
        CF_TIFF = 6
        CF_OEMTEXT = 7
        CF_DIB = 8
        CF_PALETTE = 9
        CF_PENDATA = 10
        CF_RIFF = 11
        CF_WAVE = 12
        CF_UNICODETEXT = 13
    End Enum

    Private Sub WriteToClipboard(ByVal text As String)

        Dim pText As IntPtr = Marshal.StringToHGlobalUni(text)
        Dim hReturn = SetClipboardData(uFormat.CF_UNICODETEXT, pText)

        ' If SetClipboardData succeeds, the system owns the object identified by the hMem parameter.
        ' The application may not write to or free the data
        If hReturn <> 0 Then
        End If
    End Sub


Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

Access directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version