大佬们这段VB如何转化成VFP
引用:使用()注意:该方法需要一个StringCollection对象。下面的代码可以被正确执行。要保证复制的文件存在。
Dim path As New System.Collections.Specialized.StringCollection
path.Add("D:\aaaa.xml")
(path)
** ** 剪贴板在不同应用中复制粘贴文件 ** 参考:https://msdn./en-us/library/windows/desktop/ff468802(v=vs.85).aspx ** ** ** 示例1 ** 先在资源管理器选择“复制”,然后运行本代码。 ** DECLARE LONG IsClipboardFormatAvailable IN user32 LONG DECLARE LONG OpenClipboard IN user32 LONG DECLARE LONG CloseClipboard IN user32 DECLARE LONG GetClipboardData IN user32 LONG DECLARE LONG DragQueryFile IN shell32 LONG, LONG, STRING@, LONG #DEFINE CF_HDROP 15 DIMENSION aFiles[1] IF _GetClipFiles(@aFiles) FOR i=1 TO ALEN(aFiles) ?aFiles[i] ENDFOR ENDIF CLEAR DLLS RETURN FUNCTION _GetClipFiles(aFiles) IF IsClipboardFormatAvailable(CF_HDROP) == 0 RETURN .F. ENDIF IF OpenClipboard(0) == 0 RETURN .F. ENDIF LOCAL hDrop hDrop = GetClipboardData(CF_HDROP) IF hDrop == 0 CloseClipboard() RETURN .F. ENDIF LOCAL i, nFiles, sBuf, nBufSize nFiles = DragQueryFile(hDrop, -1, NULL, 0) DIMENSION aFiles[nFiles] FOR i=0 TO nFiles-1 nBufSize = DragQueryFile(hDrop, i, NULL, 0) + 1 sBuf = SPACE(nBufSize) DragQueryFile(hDrop, i, @sBuf, nBufSize) aFiles[i+1] = RTRIM(sBuf, 0h00) ENDFOR CloseClipboard() RETURN .T. ENDFUNC ** ** 示例2 ** 假设要复制 C:\TEMP\test1.txt和C:\TEMP\test2.txt文件 ** 先运行本代码,然后在资源管理器选择“粘贴” ** DECLARE LONG OpenClipboard IN user32 LONG DECLARE LONG EmptyClipboard IN user32 DECLARE LONG CloseClipboard IN user32 DECLARE LONG SetClipboardData IN user32 LONG, LONG DECLARE LONG GlobalAlloc IN kernel32 LONG, LONG DECLARE LONG GlobalLock IN kernel32 LONG DECLARE LONG GlobalUnlock IN kernel32 LONG #DEFINE CF_HDROP 15 #DEFINE GHND 0x0042 sFiles = "C:\TEMP\test1.txt" + 0h00 + "C:\TEMP\test2.txt" + 0h0000 _SetClipFiles(sFiles) CLEAR DLLS RETURN ** typedef struct _DROPFILES { ** DWORD pFiles; // Offset of the list 4 Byte ** POINT pt; // Drop coordinates 8 Byte ** BOOL fNC; // Client or nonclient area 4 Byte ** BOOL fWide; // ANSI or Unicode text 4 Byte ** } DROPFILES, FAR* LPDROPFILES; 20 Byte FUNCTION _SetClipFiles(sFiles) IF OpenClipboard(0) == 0 RETURN .F. ENDIF LOCAL hDrop, pDrop, stDROPFILES EmptyClipboard() stDROPFILES = BINTOC(20, "4RS") + REPLICATE(0h00, 16) + sFiles hDrop = GlobalAlloc(GHND, LEN(stDROPFILES)) pDrop = GlobalLock(hDrop) SYS(2600, pDrop, LEN(stDROPFILES), stDROPFILES) GlobalUnlock(hDrop) SetClipboardData(CF_HDROP, hDrop) CloseClipboard() RETURN .T. ENDFUNC