#Include "window9.bi"

Function SetClipboardFile(sFile As String) As Integer export
	If OpenClipboard(0) Then
		Dim df As DROPFILES Ptr
		Dim hGlobal As HGLOBAL
		Dim iLen As Integer

		sFile = sFile + Chr(0) + Chr(0)
		iLen = Len(sFile)
		hGlobal = GlobalAlloc(GMEM_SHARE+GMEM_MOVEABLE+GMEM_ZEROINIT, SizeOf(DROPFILES) + iLen)

		If hGlobal<>0 Then
			df = GlobalLock(hGlobal)
			df->pFiles = SizeOf(DROPFILES)
			MoveMemory(Cast(Byte Ptr,df) + SizeOf(DROPFILES), SAdd(sFile), iLen )
			GlobalUnlock(hGlobal)
			If SetClipboardData(CF_HDROP, hGlobal)Then
				GlobalFree(hGlobal)
				Function = TRUE
			EndIf
		EndIf
		CloseClipboard()
	EndIf
End Function