您的位置首页生活小窍门

VB,API函数SHFileOperation的问题

VB,API函数SHFileOperation的问题

这个问题可以这样的解决:vb6下编译通过的。Option ExplicitPrivate Const FO_MOVE = &H1Private Const FO_COPY = &H2Private Const FO_DELETE = &H3Private Const FO_RENAME = &H4Private Const FOF_NOCONFIRMATION = &H10Private Const FOF_NOCONFIRMMKDIR = &H200Private Const FOF_ALLOWUNDO = &H40Private Const FOF_MULTIDESTFILES = &H1Private Type SHFILEOPSTRUCThWnd As LongwFunc As LongpFrom As StringpTo As StringfFlags As IntegerfAborted As BooleanhNameMaps As LongsProgress As StringEnd TypePrivate Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As LongPrivate Sub Command1_Click()Dim SHFileOp As SHFILEOPSTRUCTSHFileOp.wFunc = FO_COPYSHFileOp.pFrom = "g:\aa.txt" + Chr(0) + "g:\bb.txt" + Chr(0)SHFileOp.pTo = "陪坦毕g:\bmp"SHFileOp.fFlags = FOF_ALLOWUNDO + FOF_MULTIDESTFILESSHFileOperation SHFileOpEnd Sub注意:这样信铅的一段代码就可以完成你的任务,其中SHFileOp.pFrom = "g:\aa.txt" + Chr(0) + "g:\bb.txt" + Chr(0)aa.txt和bb.txt是任意写的东西,在每个芦芹文件之间要加上chr(0)分隔符。SHFileOp.fFlags = FOF_ALLOWUNDO + FOF_MULTIDESTFILESflags可以任意的组合。