Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to copy file reference to Windows clipboard
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00577850
Message ID:
00578071
Vues:
500
Alex, thanks...that's BEAUTIFUL!!! Now (beg, beg) can you also show the code to get CF_FILE data from the clipboard. In other words, assume I had selected some files using windows explorer, rightclicked, and then chose "copy". How do I get those file references off the clipboard within VFP? Thanks very much.
>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.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform