*Forum: Visual FoxPro Category: Third party products Title: Re: Putting pictures in a zip file Thread #466323 Message #467098 * SHFileOperation() Delete usage example: * Windows doesn't require user intervention to confirm the deletions. * Progress dialog will appear in the current active window if it takes * long enough to fire the dialog; may be idle and unresponsive for a * while with no errors. If you let the conformation dialog run, it * pops nearly instantly. * * Created by Ed Rauh * ClsHeap can be found in the Files section * lparameters cSourceString && String of files to delete DECLARE INTEGER SHFileOperation IN SHELL32.DLL STRING @ LPSHFILEOPSTRUCT DECLARE INTEGER GetActiveWindow IN WIN32API SET PROCEDURE TO CLSHEAP ADDITIVE LOCAL oHeap, cVBNull, llReturn, nStringBase, cFileOpStruct, llReturn oHeap = CREATEOBJECT('Heap') cVBNull = CHR(0) #DEFINE FO_DELETE 3 #DEFINE FOF_NOCONFIRMATION 0x10 && Don't prompt the user. #DEFINE FOF_FILESONLY 0x80 && Don't nail subfolders. * Explicitly declare a full path to avoid the vagaries of exactly what * Windows is using to resolve the path, each file spec ends with a * terminating null, with the last one double null terminated if vartype(m.cSourceString)<>"C" cSourceString = 'C:\MyDir\*.BAK' + cVBNull + ; 'C:\YourDir\YourFileName.TXT' + cVBNull + ; 'C:\MyDir\MyTempDBF.*' + cVBNull + cVBNull endif nStringBase = oHeap.AllocBlob(cSourceString) cFileOpStruct = NumToDWORD(GetActiveWindow()) + ; NumToDWORD(FO_DELETE) + ; NumToDWORD(nStringBase) + ; NumToDWORD(0) + ; NumToDWORD(FOF_NOCONFIRMATION) + ; cVBNull + ; NumToDWORD(0) + ; NumToDWORD(0) llReturn = SHFileOperation(@cFileOpStruct) = 0 IF SUBST(cFileOpStruct,21,1) # cVBNull * Some part of the operation was aborted or failed llReturn = .f. ENDIF RETURN m.llReturn