#include once "window9.bi"

#ifdef UNICODE
	Sub SetClipBoardText(ByRef sText As USTRING) Export
		if len(sText) = 0 then exit sub
		Var Clip = GlobalAlloc(GMEM_MOVEABLE Or GMEM_SHARE, Len(sText)*2+2)
		OpenClipboard(0)
		EmptyClipboard()
		Var Mem = GlobalLock(Clip)
		CopyMemory(Mem, *sText, Len(sText)*2)
		GlobalUnlock(Mem)
		SetClipboardData(CF_UNICODETEXT,Clip)
		CloseClipboard()
	End Sub	
#else	
	Sub SetClipBoardText(ByRef sText As USTRING) Export
		if len(sText) = 0 then exit sub
		Var Clip = GlobalAlloc(GMEM_MOVEABLE Or GMEM_SHARE, Len(sText)+1)
		OpenClipboard(0)
		EmptyClipboard()
		Var Mem = GlobalLock(Clip)
		CopyMemory(Mem, Strptr(sText), Len(sText))
		GlobalUnlock(Mem)
		SetClipboardData(CF_TEXT,Clip)
		CloseClipboard()
	End Sub	
#EndIf
