Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: VB4/32,VB5,VB6
Expertise: Intermediate
Oct 2, 1999

Show the contents of the Recycle Bin folder

You can use the ShellExecute API function to programmatically open a window of Explorer and display the contents of the Recycle Bin. This is the function's declare:

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
    (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
    ByVal lpParameters As String, ByVal lpDirectory As String, _
    ByVal nShowCmd As Long) As Long
The first parameter is the handle of parent window, the second is the action to be peerformed (in our case is "open"), the third argument is the application to execute, the fourth is the command line for the application, the fifth is the default directory. The last specifies the style of the window (maximized, normal or minimized), and you can use the same constants accepted by VB's Shell function. As you see in the following code, the trick is to specify the special GUID of the Recicly Bin in the command string passed to Explorer:

Private Sub cmdShowRecycleBin_Click()
    ShellExecute 0, "Open", "explorer.exe", _
        "/root,::{645FF040-5081-101B-9F08-00AA002F954E}", 0&, vbNormalFocus
End Sub
The user can then select the Empty Recycle Bin command from the File menu to manually empty the Recycle Bin, if desired.
Marco Bellinaso
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date