Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Putting pictures in a zip file
Message
General information
Forum:
Visual FoxPro
Category:
Third party products
Miscellaneous
Thread ID:
00466323
Message ID:
00467098
Views:
37
>Thanks, Ed,
>I have your code as well as an earlier thread on the subject.
>

No problem; for people who might want to see how it would work (requires using ClsHeap or an equivalent memory manager to handle the buffers:
*  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.
*
*  ClsHeap can be found in the Files section
*
DECLARE INTEGER SHFileOperation IN SHELL32.DLL STRING @ LPSHFILEOPSTRUCT
DECLARE INTEGER GetActiveWindow IN WIN32API
SET PROCEDURE TO CLSHEAP ADDITIVE
oHeap = CREATEOBJ('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
cSourceString = 'C:\MyDir\*.BAK' + cVBNull + ;
                'C:\YourDir\YourFileName.TXT' + cVBNull + ;
                'C:\MyDir\MyTempDBF.*' + cVBNull + cVBNull
nStringBase = oHeap.AllocBlob(cSourceString)
cFileOpStruct = NumToDWORD(GetActiveWindow()) + ;
                NumToDWORD(FO_DELETE) + ;
                NumToDWORD(nStringBase) + ;
                NumToDWORD(0) + ;
                NumToDWORD(FOF_NOCONFIRMATION) + ;
                cVBNull + ;
                NumToDWORD(0) + ;
                NumToDWORD(0)
IF SHFileOperation(@cFileOpStruct) = 0
   *  It worked
ELSE
   *  It didn't
ENDIF
IF SUBST(cFileOpStruct,21,1) # cVBNull
   *  Some part of the operation was aborted or failed
ENDIF
oHeap = ''
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Reply
Map
View

Click here to load this message in the networking platform