FreeBasic: Zwischenablage
#INCLUDE "Windows.bi"
Declare sub WRITEclipboard(text as string)
Declare function READclipboard() as string
dim a$
do
input a$
WRITEclipboard(a$)
sleep
? READclipboard()
loop
sub WRITEclipboard(text as string)
dim lpMem as any ptr
Dim hGlobalClip as any ptr
hGlobalClip = GlobalAlloc(GMEM_MOVEABLE Or GMEM_SHARE, len(text)+1)
OpenClipboard(0)
EmptyClipboard()
lpMem=GlobalLock(hGlobalClip)
lstrcpy(lpMem, strptr(text))
GlobalUnlock(lpMem)
SetClipboardData (CF_TEXT, hGlobalClip)
CloseClipboard()
end sub
function READclipboard() as string
dim hGlobal as any ptr
dim pGlobal as any ptr
dim txt as string
OpenClipboard(0)
hGlobal = GetClipboardData(1)
if hGlobal then
pGlobal = GlobalLock(hGlobal)
txt=space(lstrlen(pGlobal)) 'Txt auf die Länge des Clipboards bringen
lstrcpy(strptr(txt), pGlobal)
READclipboard=txt
end if
CloseClipboard ()
end function
Dieser Quellcode wurde von MichaelFrey am 02.07.2006 mit der Freebasic Version 0.16 Beta getestet.