Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to copy file reference to Windows clipboard
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00577850
Message ID:
00578014
Views:
132
Hi,
It seems to be working:
#define CF_FILES 15
#define GMEM_MOVEABLE 2
#define GMEM_ZEROINIT 64

Declare Long GlobalAlloc in Win32API Long uFlags, Long dwBytes
Declare Long GlobalFree in Win32API Long hMem
Declare Long GlobalLock in Win32API Long hMem
Declare Long GlobalUnlock in Win32API Long hMem
Declare RtlMoveMemory in Win32API Long lpDest, String @ lpStr, Long lLen
Declare Long OpenClipboard in Win32API Long
Declare Long CloseClipboard in Win32API
Declare Long EmptyClipboard in Win32API
Declare Long SetClipboardData in Win32API Long uFormat, Long hMem
Declare Long GetLastError in Win32API

* _DROPFILES structure
s = Chr(20) + Replicate(Chr(0), 19)
s = s + "c:\autoexec.bat" + Chr(0)
s = s + "c:\config.sys" + Chr(0) + Chr(0)

h = GlobalAlloc(GMEM_MOVEABLE+GMEM_ZEROINIT, LEN(s))
ptr = GlobalLock(h)
RtlMoveMemory(ptr, s, LEN(s))
GlobalUnlock(h)
If OpenClipboard(0) != 0
	EmptyClipboard()
	SetClipboardData(CF_FILES, h)
	CloseClipboard()
else
	GlobalFree(h)
EndIf
>Hilmar, thank you, but copying the name to the clipboard as a text item (CF_TEXT format) does not solve the problem. I need to be able to put an object of type CF_FILES onto the windows clipboard (for doing a copy function) and access such objects on the windows clipboard (for doing a paste function), just like you can do with getdata/setdata when using OLE drag-and-drop. Putting a text object on the clipboard that happens to be a file name is not sufficient.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform