Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


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

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.

.
Summary
Set Clipboad data(Text, bitmap, etc).
Relation
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:

None.

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

' THIS SAMPLE CONTAINS ERROR.

' ATTENTION PLEASE AND CARE THIS SAMPLE.

    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 Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim strUManage As New StringPtr("CopyString")

    OpenClipboard(Nothing)
    EmptyClipboard()
    SetClipboardData(uFormat.CF_UNICODETEXT, strUManage.GetIntPtr)      ' copy to clipboad
    CloseClipboard()

    strUManage.Free()    ' error occur.
    End Sub

    ' http://www.microsoft.com/japan/msdn/net/compactframework/netcfadvinterop.aspx
    Public Class Memory
    ...
    ' Replace this sub
    Public Shared Sub FreeHLocal(ByVal hlocal As IntPtr)
        If Not hlocal.Equals(IntPtr.Zero) Then
        If Not IntPtr.Zero.Equals(LocalFree(hlocal)) Then
            ' Occurs Error. may be memory leak.
            MessageBox.Show("LocalFree Fail" & Marshal.GetLastWin32Error())
            'Throw New System.ComponentModel.Win32Exception(Marshal.GetLastWin32Error())
        End If
        hlocal = IntPtr.Zero
        End If
    End Sub
    ...
    End Class
    Public Structure StringPtr
    ...
    ' Add this Property
    Public ReadOnly Property GetIntPtr() As IntPtr
        Get
        Return szString
        End Get
    End Property
    End Structure

Documentation

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 PInvoke.net directly from VS:
Terms of Use
Find References
Show Printable Version
Revisions