'存储到 Windows 剪贴板中的文本字符串。
'Dim sText As String = "This is my text to copy"
'FF_ClipboardSetText(sText)
Function FF_ClipboardSetText(ByRef x As String) As Integer
   Function = False
   Dim As HANDLE hText = Null
   Dim As UByte Ptr clipmem = Null
   Dim As Integer n = Len(x)
   If n > 0 Then
      hText = GlobalAlloc(GMEM_MOVEABLE Or GMEM_DDESHARE, n + 1)
      Sleep 15
      If (hText) Then
         clipmem = GlobalLock(hText)
         If clipmem Then
            CopyMemory(clipmem, Strptr(x), n)
         Else
            hText = Null
         End If
         If GlobalUnlock(hText) Then
            hText = Null
         End If
      End If
      If (hText) Then
         If OpenClipboard(Null) Then
            Sleep 15
            If EmptyClipboard() Then
               Sleep 15
               If SetClipboardData(CF_TEXT, hText) Then
                  Sleep 15
                  Function = True
               End If
            End If
            CloseClipboard()
         End If
      End If
   End If
End Function
