Hi Guys:
I think the title explains itself. Please have a look at my code and see why is not working.
many of you may suggest to empty the folder from file and subfolders but actually, in many cases it causing me a lot of crashes. as well, I need what the title says:
#constant Shell32DllNo = 1
load Dll "Shell32.dll", Shell32DllNo //call shell32 dll and give it an ID number.
MyFileToRecycle$ = dir desktop() + "\aa.txt" //just create this file on the desktop.
Type SHELL_PARAMETERS // we needs this parameters to pass to the dll, in DBpro, we call it type. Refer to structures(struct) in c++.
hWnd As dword //window handle. If ignored it will use the current active window from the exe. So i ignored it.
wFunc As dword //although it refer to function but actually is an option such as Delete, copy, sento recycle bin ETC..........
pFrom$ As String //file to perform operation on.
pTo As String //I think it only used if we want to copy or move a file.
fFlags As integer //control whether the windows is required to prompt the user, I looked around and what I found that 0x0040 means to ignore any messaging.
fAnyOperationsAborted As dword // return 0 if operation is successful
hNameMappings As dword // no Idea
lpszProgressTitle As dword // no Idea
EndType
dim _PAR(0) As SHELL_PARAMETERS //in DBpro better to create an array for the type rather than a single parameter. Because we need to send a reference to the DLL. However, this is not the case in general.
_PAR(0).wFunc = 0x0003 //this Option is supposed to send the file or folder to recycle bin. I am more interested in deleting it totally, but all web pages I searched are referring to CO_DELETE without mentioning its value.
_PAR(0).pFrom$ = MyFileToRecycle$ //file name refered earlier.
_PAR(0).fFlags = 0x0040 //don’t promt any message.
_result = call dll(Shell32DllNo, "SHFileOperation", _PAR(0)) //call the DLL by number and what function within the DLL we need to use. And then pass the parmameters in _PAR(0). //in c++ you will need to use &_par because actually you’re passing the memory address NOT the variable.
if _PAR(0).fAnyOperationsAborted = 0 //now check if the operation is successfull
print "File deleted"
ELSE
print "Operation aborted"
ENDIF
wait key
end
by the way there was a post in 2009 to address similar issue but just tried it this morning and didn't work.