Recycle Bin in Windows part 2

In the first part I showed how to delete a file (yet another different way) and how to clear Recycle Bin. Clearing Recycle Bin was most special since API call that did the work wasn't present in API Viewer. And now here is something even more special: opening Recycle Bin straight from your app!

Now to accomplish the task, there was a trick that had to be used worth knowing. You see, in Windows environment, stuff like My Computer, Control Panel, and Recycle Bin are all shown by one singe application (explorer.exe i believe). This is sort of hidden from the user since she/he doesn't care what is showing the content, because the content is what matters. Well for us, to view Recycle Bin, we will use eplorer.exe with special calling sequence. Here is the code:

Public Sub ShowRecyclebin()
'shows the recycle bin
On Error Resume Next

Dim sGuid As String

'recycles bin GUID retrieved from the registry
sGuid = "::{645ff040-5081-101b-9f08-00aa002f954e}"
'sGuid = "::{BDEADF00-C265-11D0-BCED-00A0C90AB50F}"
'for My computer
'for more constants, search your registry
'or look at some registry resource
'explorer can show many things, just pass
'guid of the object you want to show
'as a parameter for ShellExecute function

ShellExecute 0&, "Open", "explorer.exe" & Chr$(0), _
"/root," & sGuid, 0&, SW_MAX
End Sub

Again, not that complicated right? It's just knowing the right trick. I also showed you GUID for My Computer window. There are more of them but I didn't bother scouting registry for them. If there is someone really interested and dies to know some GUIDs please let me know.

Written By Laimonas Simutis. 2002. laijerrad@yahoo.com