FAQ003 = How can I access the Windows clipboard from QBasic?
1) You must have QBasic 4.5+
2) You must remember to use the /L switch to include the qb.qlb.
3) If you have NT, 2K, or XP then (thanks, Plasma) you need to run NTOLDAPP before calling QBasic /L. If you don't have this program, download:
ftp://ftp.muc.de/people/cfaerber/comp/xp/ntold09b.zip
Here is a demo program showing how the clipboard is accessed.
This accesses interrupt &H2F, functions &H17## to manipulate the text clipboard (there are different clipboards for the different types of data). Note that, if the clipboard contains a lot of data, then you may not be able to open it.
Your program needs to open the clipboard before using the rest of the subs/functions. It should keep the clipboard open for as little time as possible, because other programs can't use the clipboard while it is open.
DECLARE FUNCTION ClipboardText$ ()
DECLARE SUB OpenClipboard ()
DECLARE SUB CloseClipboard ()
DECLARE SUB SetClipboardText (text$)
DECLARE SUB EmptyClipboard ()
'$INCLUDE: 'qb.bi'
DIM SHARED regs AS regTypeX
CLS
PRINT "Demo of read and write clipboard"
PRINT
OpenClipboard
PRINT "Previous clipboard text: "; ClipboardText$
SetClipboardText "This will be replaced"
SetClipboardText "Hello, World!"
PRINT "New clipboard text: "; ClipboardText$
CloseClipboard
SYSTEM