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:
00578918
Vues:
250
>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?

In reverse order :)
#define CF_FILES 15

Declare Long GlobalLock in Win32API Long hMem
Declare Long GlobalUnlock in Win32API Long hMem
Declare Long OpenClipboard in Win32API Long
Declare Long CloseClipboard in Win32API
Declare Long GetClipboardData in Win32API Long uFormat
Declare Long EnumClipboardFormats in Win32API Long lFormat
Declare Long DragQueryFile in shell32.dll Long hDrop, Long iFiles, String @cFiles, Long lSize

If(OpenClipboard(0) != 0)
* More correct way to check format of clipboard data
*!*		f = EnumClipboardFormats(0)
*!*		Do While f > 0 and f != CF_FILES
*!*			f = EnumClipboardFormats(f)
*!*		EndDo

*!*		If f = CF_FILES		&& File names in clipboard
	h = GetClipBoardData(CF_FILES)
	If h > 0				&& File names in clipboard
		ptr = GlobalLock(h)
		nFiles = DragQueryFile(ptr, -1, NULL, 0)
		For i = 0 To nFiles - 1
			s = Replicate(Chr(0), 256)	&& File name buffer
			DragQueryFile(@ptr, i, @s, 256) && Get next file name
			* Do something with file name
			MESSAGEBOX(s, 64, "File in clipboard")
		EndFor
		GlobalUnlock(h)
	Else					&& Not a file names in clipboard
		MessageBox(Left(_CLIPTEXT, 255), 64, "Clipboard")
	EndIf
	CloseClipboard()
EndIf
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform