When copying / scrapping / scrap files from the Source Manager, the file list is stored to the Clipboard CLIPBOARD. You can use the following program to get this list of files, including "copying" or "scrap".
Add a class module in VB to add the following code.
'// This article is originally created by Virtualalloc, please indicate the source.
Private Type Pointapi X As Long Y As Longend Type
Private Type Dropfiles Pfiles As Long Pt As Pointapi Fnc As Long Fwide As LONGEND TYPE
'// global memoryPrivate Declare Function GlobalAlloc Lib "kernel32" (ByVal wFlags As Long, ByVal dwBytes As Long) As LongPrivate Declare Function GlobalFree Lib "kernel32" (ByVal hMem As Long) As LongPrivate Declare Function GlobalLock Lib "kernel32" (ByVal hMem AS LongPrivate Declare Function GlobalUnlock LIB "Kernel HMEM As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RTLmoveMemory" (PDest As Any, Psrc as Any, Byval Bytelen As Long)
'ClipboardPrivate Declare Function SetClipboardData Lib "user32" (ByVal wFormat As Long, ByVal hMem As Long) As LongPrivate Declare Function EmptyClipboard Lib "user32" () As LongPrivate Declare Function RegisterClipboardFormat Lib "user32" Alias "RegisterClipboardFormatA" (ByVal lpString As String) As LongPrivate Declare Function IsClipboardFormatAvailable Lib "user32" (ByVal wFormat As Long) As LongPrivate Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As LongPrivate Declare Function GetClipboardData Lib "user32" (ByVal wFormat As Long) As LongPrivate Declare Function CloseClipboard lib "user32" () As LongPrivate Declare Function DragQueryFile lib "shell32.dll" Alias "DragQueryFileA" (ByVal hDrop As Long, ByVal iFile As Long, ByVal lpszFile As String, ByVal cch As Long) As LongPublic Enum FileDropEffectConstants fdDropEffectNone = 0 fdDropEffectCopy = 1 fddropeffectmove = 2 fddropeffectLink = 4END ENUM
'// Clipboard FormatsPrivate Const CF_TEXT = 1Private Const CF_BITMAP = 2Private Const CF_METAFILEPICT = 3Private Const CF_SYLK = 4Private Const CF_DIF = 5Private Const CF_TIFF = 6Private Const CF_OEMTEXT = 7Private Const CF_DIB = 8Private Const CF_PALETTE = 9Private Const CF_PENDATA = 10Private Const CF_RIFF = 11Private Const CF_WAVE = 12Private const cf_unicodetext = 13Private const cf_enhmetafile = 14Private const cf_hdrop = 15Private const cf_locale = 16Private const cf_max = 17
'Other clipboard formatsPrivate Const CFSTR_SHELLIDLIST As String = "Shell IDList Array" Private Const CFSTR_SHELLIDLISTOFFSET As String = "Shell Object Offsets" Private Const CFSTR_NETRESOURCES As String = "Net Resource" Private Const CFSTR_FILEDESCRIPTOR As String = "FileGroupDescriptor" Private Const CFSTR_FILECONTENTS As String = "fileContents" Private Const CFSTR_FILENAME As String = "FileName" Private Const CFSTR_PRINTERGROUP As String = "PrinterFriendlyName" Private Const CFSTR_FILENAMEMAP As String = "FileNameMap" Private Const CFSTR_PREFERREDDROPEFFECT As String = "Preferred dropEffect"
'Global memoryPrivate Const GMEM_FIXED = & H0Private Const GMEM_MOVEABLE = & H2Private Const GMEM_NOCOMPACT = & H10Private Const GMEM_NODISCARD = & H20Private Const GMEM_ZEROINIT = & H40Private Const GMEM_MODIFY = & H80Private Const GMEM_DISCARDABLE = & H100Private Const GMEM_NOT_BANKED = & H1000Private Const GMEM_SHARE = & H2000Private Const GMEM_DDESHARE = & H2000Private Const GMEM_NOTIFY = & H4000Private Const GMEM_LOWER = GMEM_NOT_BANKEDPrivate Const GMEM_VALID_FLAGS = & H7F72Private Const GMEM_INVALID_HANDLE = & H8000Private Const GHND = (GMEM_MOVEABLE Or GMEM_ZEROINIT) Private Const GPTR = (GMEM_FIXED Or GMEM_ZEROINIT)
Public Function ClipboardSetFiles (sfiles () As String, ByVal lcount As Long) As Boolean '// send files to clipboard Dim sTmp As String Dim dfs As DROPFILES Dim hGlobal As Long Dim lpGlobal As Long Dim i As Long' // Open clipboard If OpenClipboard (0) Then EmptyClipboard 'empty clipboard' // combine files For i = 0 To lcount - 1 sTmp = sTmp & sfiles (i) & vbNullChar Next sTmp = sTmp & vbNullChar hGlobal = GlobalAlloc (GHND, Len (dfs) Len (sTmp)) 'Allocate If hGlobal Then' // make DROPFILES lpGlobal = GlobalLock (hGlobal) dfs.pFiles = Len (dfs) CopyMemory ByVal lpGlobal, dfs, Len (dfs) CopyMemory ByVal lpGlobal Len (dfs), ByVal sTmp, LEN (STMP) Globalunlock Hglobal ClipboardSetFiles = setClipboardData (CF_HDROP, HGLOBAL) 'COPY Stmp To Clipboard En d If CloseClipboard 'close End If End FunctionPublic Function ClipboardGetFiles (sfiles () As String, lcount As Long, _ Optional ByRef DropEffect As FileDropEffectConstants) As Boolean' // get files from clipboard
'// If Clipboard.GetFormat (vbCFFiles) Then ........ Dim hDrop As Long Dim sTmp As String Dim i As Long Const MAX_PATH As Long = 260' // open clipboard If IsClipboardFormatAvailable (CF_HDROP) Then If OpenClipboard (0) Then 'Get Filelist data hDrop = GetClipboardData (CF_HDROP) lcount = DragQueryFile (hDrop, -1, vbNullString, 0)' file entries lcount = lcount ReDim sfiles (lcount - 1) sTmp = String (MAX_PATH, Chr (0) ) 'get file For i = 0 To lcount - 1 DragQueryFile hDrop, i, sTmp, MAX_PATH sfiles (i) = NullTrim (sTmp) Next i Dim lngFormat As Long Dim lngEffect As Long lngFormat = RegisterClipboardFormat (CFSTR_PREFERREDDROPEFFECT) hDrop = GetClipboardData (lngFormat ) (HDrop) Then CopyMemory lngEffect, ByVal hDrop, 4 DropEffect = lngEffect End If 'close Call CloseClipboard ClipboardGetFiles = True' return End If End If End FunctionPrivate Function NullTrim (ByRef inString As String) As String Dim iPos As Integer iPos = InStr (inString , Chr $ (0)) if ipos> 0 Then NullTrim = Left $ (Instring, IPOS - 1) Else NullTrim = Instring End IFEND FUNCTION
'// This article is originally created by Virtualalloc, please indicate the source.