Page 1 of 1

Tip: Emptying Recycle Bin

Posted: Thu Dec 04, 2003 1:06 am
by PB
PureBasic doesn't (yet) support the SHEmptyRecycleBin() API (probably
due to Windows 95/NT not supporting it). However, using the OpenLibrary
functions you can pretty much use any API you want (even if PureBasic
doesn't support it), so here's an example of emptying the Recycle Bin:

Code: Select all

Procedure EmptyTrash(confirm)
  If OpenLibrary(0,"shell32.dll") And IsFunction(0,"SHEmptyRecycleBinA")
    CallFunction(0,"SHEmptyRecycleBinA",0,"",1-confirm)
    CloseLibrary(0)
  EndIf
EndProcedure

EmptyTrash(1) ; 1 = confirm with user first, 0 = don't confirm.
If you need to know what functions a particular DLL has, you can find out
with the following code. However, note that this code doesn't list the
required parameters for each API function, so you may need to do a bit
of Google searching (or whatever) to find out.

Code: Select all

If OpenLibrary(0,"shell32.dll") ; Name of DLL to browse.
  If ExamineLibraryFunctions(0)
    While NextLibraryFunction()
      Debug LibraryFunctionName()
    Wend
  EndIf
  CloseLibrary(0)
EndIf
Enjoy! :)

Posted: Thu Dec 04, 2003 10:37 am
by benny
I like your code, thanks for sharing!

Posted: Thu Dec 04, 2003 10:40 am
by Berikco
It does not work, i run the code, and the recycle bin under my desk is still full, and a lot of garbage around it also :? 8O

Posted: Thu Dec 04, 2003 10:45 am
by Rings
Berikco wrote:It does not work, i run the code, and the recycle bin under my desk is still full, and a lot of garbage around it also :? 8O
you made a mistake, run a commandline and type :

del c:\Program Files\Purebasic\vd\sources\*.*

and your trashcan is empty

:mrgreen: :mrgreen: :mrgreen:

Posted: Thu Dec 04, 2003 3:23 pm
by blueb
Rings:
Excellent response! :lol:

PB:

I ran the bottom snippet and looked at all the available functions Shell32.dll provides, then opened up Win32.hlp (Win32 Programmers Reference).

Most of the functions were not listed in the help file. It appears that it was printed in 1996, so it looks like it's getting a little dated.

Is there a "newer" version available without resorting to the full SDK from Microsoft?

--blueb

Posted: Fri Dec 05, 2003 4:46 am
by PB
> Rings: Excellent response!

Agreed! :)

> Is there a "newer" version [of Win32.hlp] available without resorting to
> the full SDK from Microsoft?

Not sure... I'm using an oldish version too. Maybe someone else knows?
I'm not at my development PC right now so I can't compare sizes (oo-er)
of the file... I did change from one version to a slightly better one at some
stage. I'll post back tomorrow with version / byte size of my current file.

Posted: Sun Dec 07, 2003 4:12 am
by PB
My Win32.hlp file is 19.1 MB (20,033,075 bytes) in size.
I can't remember where I downloaded it, sorry. :(