Loading data blob to the Clipboard (using WinClip library)
Posted: 16 Mar 2024, 17:44
I'm saving data captured from the Clipboard to a Blob field in a SQLite table. Later, I want to retrieve the clip data and load it to the Clipboard.
From the SQLite table, I get the address and size of the blob in a SQLite record. I can use successfully these two fields to create a temporary file and load it to the Clipboard using the WinClip.Load() method.
Now, my question... I would like to do the same but loading the blob directly to the Clipboard without using a temporary file. I tried creating the extended method WinClipJL.SetData() below but it does not work. Do you see what could be wrong? There may be a problem the way I prepare the data for the _toclipboard() method?
I could post a working example but maybe one can help me just reading these code snippets? Thanks.
From the SQLite table, I get the address and size of the blob in a SQLite record. I can use successfully these two fields to create a temporary file and load it to the Clipboard using the WinClip.Load() method.
Code: Select all
; intAddr: address of a SQLite Blob field containing data captured earlier from the Clipboard
; intSize: size of the same SQLite Blob field
hFileData := FileOpen(strFilePath, "w")
VarSetCapacity(oBlob, intSize)
DllCall("Kernel32.dll\RtlMoveMemory", "Ptr", &oBlob, "Ptr", intAddr, "Ptr", intSize)
hFileData.RawWrite(&oBlob, intSize)
hFileData.Close()
WinClip.Load(strFilePath) ; this is working
Code: Select all
; intAddr: address of a SQLite Blob field containing data captured earlier from the Clipboard
; intSize: size of the same SQLite Blob field
; prepare the Blob for WinClipJL.SetData()
VarSetCapacity(oBlob, intSize)
DllCall("Kernel32.dll\RtlMoveMemory", "Ptr", &oBlob, "Ptr", intAddr, "Ptr", intSize)
; call WinClip extended method SetData
intSetSize := WinClipJL.SetData(oBlob, intSize) ; this is NOT working
Code: Select all
class WinClipJL extends WinClip
{
SetData( dataBuff, dataSize )
; adaped from the WinClip.Load() method
{
if !( size := this._toclipboard( dataBuff, dataSize ) )
return 0
return size
}
}