Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
;SHFileOperations - MWorrel, 10/13/2003 ;========================================== ;WARNING!!!! Almost completely untested--use at your own peril!! #DefineFunction SHFileOP (Operation,FromList,ToList,Flags) OpStruct=BinaryAlloc(32) pFrom=BinaryAlloc (StrLen(FromList)+ItemCount(FromList,@TAB)+1) pTo=BinaryAlloc (StrLen(ToList)+ItemCount(ToList,@TAB)+1) For EachObj=1 To ItemCount (FromList,@TAB) ThisObj=ItemExtract (EachObj,FromList,@TAB) BinaryPokeStr (pFrom,BinaryEODGet(pFrom),ThisObj) BinaryEODSet (pFrom,BinaryEODGet(pFrom)+1) Next BinaryEODSet (pFrom,BinaryEODGet(pFrom)+1) For EachObj=1 To ItemCount (ToList,@TAB) ThisObj=ItemExtract (EachObj,ToList,@TAB) BinaryPokeStr (pTo,BinaryEODGet(pTo),ThisObj) BinaryEODSet (pTo,BinaryEODGet(pTo)+1) Next BinaryEODSet (pTo,BinaryEODGet(pTo)+1) BinaryPoke4 (OpStruct,4,Operation) BinaryPoke4 (OpStruct,8,IntControl(42,pFrom,0,0,0)) BinaryPoke4 (OpStruct,12,IntControl(42,pTo,0,0,0)) BinaryPoke4 (OpStruct,16,Flags) ShellOp=DllCall (StrCat(DirWindows(1),"Shell32.dll"),long:"SHFileOperationA",lpbinary:OpStruct) LastErr=DllCall (StrCat(DirWindows(1),"Kernel32.dll"),long:"GetLastError") BinaryFree(OpStruct) BinaryFree (pFrom) BinaryFree (pTo) Return (ShellOp) #EndFunction ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;Flags: ;FOF_ALLOWUNDO = 64 ;Preserves undo information, if possible. ;FOF_CONFIRMMOUSE = 2 ;Not implemented. ;FOF_FILESONLY = 128 ;Performs the operation only on files if a wildcard filename (*.*) is specified. ;FOF_MULTIDESTFILES = 1 ;Indicates that the pTo member specifies multiple destination files (one for each source file) rather than one directory where all source files are to be deposited. ;FOF_NOCONFIRMATION = 16 ;Responds with "yes to all" for any dialog box that is displayed. ;FOF_NOCONFIRMMKDIR = 512 ;Does not confirm the creation of a new directory if the operation requires one to be created. ;FOF_RENAMEONCOLLISION = 8 ;Gives the file being operated on a new name (such as "Copy #1 of...") in a move, copy, or rename operation if a file of the target name already exists. ;FOF_SILENT = 4 ;Does not display a progress dialog box. ;FOF_SIMPLEPROGRESS = 256 ;Displays a progress dialog box, but does not show the filenames. ;FOF_WANTMAPPINGHANDLE = 32 ;Fills in the hNameMappings member. The handle must be freed by using the ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;+------------------+ ;|Operation Codes: | ;|FO_MOVE = 1 | ;|FO_COPY = 2 | ;|FO_DELETE = 3 | ;|FO_RENAME = 4 | ;+------------------+ ;This test relies on having a C:\test\test.txt file... MoveTest=SHFileOp (1,"C:\Test\Test.txt","C:\Test\Moved.txt",64|512) Message ("Result:",MoveTest) CopyTest=SHFileOp (2,"C:\Test\Moved.txt","C:\Test\",8|64|512) Message ("Result:",CopyTest) DelTest=SHFileOp (3,"C:\Test\Copy*.txt","",64|512) Message ("Result:",DelTest) RenTest=SHFileOp (4,"C:\Test\Moved.txt","C:\Test\Renamed.txt",64|512) Message ("Result:",RenTest) Exit ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;typedef struct _SHFILEOPSTRUCT { ; HWND hwnd (1-3) ; UINT wFunc (4-7) ; LPCTSTR pFrom (8-11) ; LPCTSTR pTo (12-15) ; FILEOP_FLAGS fFlags (16-19) ; BOOL fAnyOperationsAborted (20-23) ; LPVOID hNameMappings (24-27) ; LPCTSTR lpszProgressTitle (28-31)
Article ID: W16206
File Created: 2004:03:30:15:43:14
Last Updated: 2004:03:30:15:43:14