# BBC BASIC Programmers' Reference

### Site Tools

accessing_20the_20shell_20clipboard

# Differences

This shows you the differences between two versions of the page.

 accessing_20the_20shell_20clipboard [2018/03/31 13:19]127.0.0.1 external edit accessing_20the_20shell_20clipboard [2018/04/17 14:59] (current)tbest3112 Added syntax highlighting 2018/04/17 14:59 tbest3112 Added syntax highlighting2018/03/31 13:19 external edit 2018/04/17 14:59 tbest3112 Added syntax highlighting2018/03/31 13:19 external edit Line 2: Line 2: //by Richard Russell, October 2010//\\ \\ **Windows Explorer** lets you copy files from one place in the filesystem to another (e.g. from one folder to another, or from one drive to another) by means of **Copy** and **Paste** operations, analogous to how you might copy-and-paste text from one document to another. This article describes how you can access the **Shell Clipboard** from your BASIC program, so you can **paste** files that have been copied in Windows Explorer, or **copy** files that can then be pasted in Windows Explorer.\\ \\ **Pasting** files from the Shell Clipboard uses a similar mechanism to that described in the article [[/​Receiving%20dropped%20files|Receiving dropped files]]. The following code checks to see if there are any files on the Shell Clipboard and if so accesses them:​\\ ​ //by Richard Russell, October 2010//\\ \\ **Windows Explorer** lets you copy files from one place in the filesystem to another (e.g. from one folder to another, or from one drive to another) by means of **Copy** and **Paste** operations, analogous to how you might copy-and-paste text from one document to another. This article describes how you can access the **Shell Clipboard** from your BASIC program, so you can **paste** files that have been copied in Windows Explorer, or **copy** files that can then be pasted in Windows Explorer.\\ \\ **Pasting** files from the Shell Clipboard uses a similar mechanism to that described in the article [[/​Receiving%20dropped%20files|Receiving dropped files]]. The following code checks to see if there are any files on the Shell Clipboard and if so accesses them:​\\ ​ + CF_HDROP = 15 CF_HDROP = 15 MAX_PATH = 260 MAX_PATH = 260 Line 25: Line 26: SYS "​CloseClipboard"​ SYS "​CloseClipboard"​ ENDIF ENDIF + ​ Here the filenames are simply printed to the screen. In practice you are likely to want to copy the files and/or to access their contents.\\ \\ **Copying** files to the Shell Clipboard is slightly more involved, because you have to build the necessary data structure yourself. The code to do it is listed below; for convenience it uses the **FNselectfiles** function, to be found in the article [[/​Selecting%20multiple%20files|Selecting multiple files]], to select the file(s) to be copied:​\\ ​ Here the filenames are simply printed to the screen. In practice you are likely to want to copy the files and/or to access their contents.\\ \\ **Copying** files to the Shell Clipboard is slightly more involved, because you have to build the necessary data structure yourself. The code to do it is listed below; for convenience it uses the **FNselectfiles** function, to be found in the article [[/​Selecting%20multiple%20files|Selecting multiple files]], to select the file(s) to be copied:​\\ ​ + CF_HDROP = 15 CF_HDROP = 15 GMEM_ZEROINIT = &40 GMEM_ZEROINIT = &40 Line 52: Line 55: SYS "​CloseClipboard"​ SYS "​CloseClipboard"​ ENDIF ENDIF +