Tip: Emptying Recycle Bin

Share your advanced PureBasic knowledge/code with the community.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Tip: Emptying Recycle Bin

Post 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! :)
benny
Enthusiast
Enthusiast
Posts: 465
Joined: Fri Apr 25, 2003 7:44 pm
Location: end of www
Contact:

Post by benny »

I like your code, thanks for sharing!
regards,
benny!
-
pe0ple ar3 str4nge!!!
Berikco
Administrator
Administrator
Posts: 1326
Joined: Wed Apr 23, 2003 7:57 pm
Location: Belgium
Contact:

Post 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
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

Post 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:
SPAMINATOR NR.1
User avatar
blueb
Addict
Addict
Posts: 1111
Joined: Sat Apr 26, 2003 2:15 pm
Location: Cuernavaca, Mexico

Post 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
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post 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.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post 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. :(
Post Reply