I’m trying to allow copy and paste of stored documents to outlook etc
Using winevent I’ve used the example code for ds_setclipboard, which I’ve placed under a button in my program.
In my test environment nothing happens
In Production under TSPlus I get a SetClipboard Failed error.
The code is pretty much from the docs
Any clues anyone??
data
hDropStruct group
pFiles long ! offset from here to FileList
pt ulong ! drop point (in screen co-ords)
blank ulong
fNC long !Set for Non-Client area.
fWide long
FileList string(255) ! Null terminated list of null terminated file names.
end
code
hDropStruct.filelist = ‘C:\autoexec.bat<0,0>’ ! List of files. Note the double null terminator.
hDropStruct.pFiles = 20
hDropStruct.fWide = 0 ! ASCII
if ~ds_SetClipboard(CF_hDrop,hDropStruct) ! Place name in clipboard.
message(‘SetClipboardFailed’)
end
Hi Guys to be clear, it looks like this winevent call succeeds on my system but fails at the clients. The client is runnin Terminal services (TSPlus) on Win server 2008
Update: I’m now not sure that winevent is doing the right thing. I’ve created a small test app (C10 src below) which appears to work on my system, excepting that I can’t paste anywhere.
Bruce has been emailed
DropFiles structure consists of 5 LONGs so 20 is correct. You need to allocate memory for this structure and file list which follows this structure and pass memory handle to SetClipBoardData call, VB code is below. It looks pretty much straight forward
Public Function ClipboardCopyFiles(Files() As String) As Boolean
Dim data As String
Dim df As DROPFILES
Dim hGlobal As Long
Dim lpGlobal As Long
Dim i As Long
’ Open and clear existing crud off clipboard.
If OpenClipboard(0&) Then
Call EmptyClipboard
’ Build double-null terminated list of files.
For i = LBound(Files) To UBound(Files)
data = data & Files(i) & vbNullChar
Next
data = data & vbNullChar
’ Allocate and get pointer to global memory,
’ then copy file list to it.
hGlobal = GlobalAlloc(GHND, Len(df) + Len(data))
If hGlobal Then
lpGlobal = GlobalLock(hGlobal)
Update: I upgraded to winevent5 (I was on 3.99 Don’t know how I missed that upgrade).
That made things worse, winevent5 crashes explorer.
However it is now source, so I could find out what was happening, and more importantly fix it.
It now works. I can copy files and paste into an explorer window. Yeah!
The code has been sent to Capesoft.