Private Declare Function OpenClipboard Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function SetClipboardData Lib "user32" (ByVal Format As Long, ByVal hMem As Long) As Long
Private Declare Function CloseClipboard Lib "user32" () As Long
Private Declare Function EmptyClipboard Lib "user32" () As Long
Private Declare Function GlobalAlloc Lib "kernel32" (ByVal Flags As Long, ByVal length As Long) As Long
Private Declare Function GlobalLock Lib "kernel32" (ByVal hMem As Long) As Long
Private Declare Function GlobalUnlock Lib "kernel32" (ByVal hMem As Long) As Long
Private Declare Sub RtlMoveMemory Lib "kernel32" (ByVal pDest As Long, ByVal pSource As Long, ByVal length As Long)
Private Const CF_UNICODETEXT = &HD&
Private Const GMEM_MOVEABLE = &O2&
Private Const GMEM_ZEROINIT = &O40&
Dim hMem As Long, pMem As Long, StringToCopy As String
StringToCopy = txtMessage.Text & " " & Now()
Call OpenClipboard(Me.hWnd)
Call EmptyClipboard
hMem = GlobalAlloc(GMEM_MOVEABLE Or GMEM_ZEROINIT, LenB(StringToCopy) + 2)
pMem = GlobalLock(hMem)
Call RtlMoveMemory(pMem, StrPtr(StringToCopy), LenB(StringToCopy) + 2)
Call GlobalUnlock(hMem)
Call SetClipboardData(CF_UNICODETEXT, hMem)
Call CloseClipboard
Title:
Copy text unicode to clipboard with VB6
Description:
Private Declare Function OpenClipboard Lib "user32" (ByVal hWnd As Long) As Long Private Declare Function SetClipboardData Lib ...
...
Rating:
4