AllAPI Network - The KPD-Team

Allapi Network

 API List

API Resources
 Tips & Tricks
 VB Tutorials
 Error Lookup
Misc Stuff
 VB examples
 VB Tools
 VB Links
 Top Downloads
This Site
 Search Engine
 Contact Form

Donate to

How to change the name of the Recycle Bin through VB?

By right clicking on the Recycle Bin Windows doesnīt give you the option to change the name like other Shortcuts. 

This trick shows how to enter the registry and change the Recycle Bin name setting.

Create a new project with 1 module and 1 form.

Module Declarations

Public Const EWX_LOGOFF = 0
Public Const EWX_SHUTDOWN = 1
Public Const EWX_REBOOT = 2
Public Const EWX_FORCE = 4

Declare Function ExitWindowsEx Lib "user32" (ByVal _
uFlags As Long, ByVal dwReserved As Long) As Long

Public Const HKEY_CLASSES_ROOT = &H80000000
Declare Function RegCreateKey Lib "advapi32.dll" _
Alias "RegCreateKeyA" (ByVal Hkey As Long, ByVal _
lpSubKey As String, phkResult As Long) As Long
Declare Function RegCloseKey Lib "advapi32.dll" _
(ByVal Hkey As Long) As Long
Declare Function RegSetValueEx Lib "advapi32.dll" _
Alias "RegSetValueExA" (ByVal Hkey As Long, ByVal _
lpValueName As String, ByVal Reserved As Long, ByVal _
dwType As Long, lpData As Any, ByVal cbData As Long) _
As Long

Public Const REG_SZ = 1
Public Const REG_DWORD = 4   

Public Sub savestring(Hkey As Long, strPath As _
String, strValue As String, strdata As String)
Dim keyhand As Long
Dim r As Long
r = RegCreateKey(Hkey, strPath, keyhand)
r = RegSetValueEx(keyhand, strValue, 0, _
REG_SZ, ByVal strdata, Len(strdata))
r = RegCloseKey(keyhand)
End Sub

Form Code

On the form put 1 command button and add the following code to the click event:

Private Sub Command1_Click() 
'prompts for new name

strString$ = InputBox("Please type in a string to save to the Registry.", "Recycle Bin") 
If strString$ = Empty Then 
    'string is empty or cancel is pressed
    MsgBox "Empty String", vbCritical, "Error"
    Exit Sub
End If

'API call to store new name
Call savestring(HKEY_CLASSES_ROOT, _
"CLSID\{645FF040-5081-101B-9F08-00AA002F954E}", _
(pre), strString$)

MsgBox "Reset your PC", , "Changes are made"
'resets your PC

t& = ExitWindowsEx(EWX_FORCE Or EWX_REBOOT, 0)
End Sub

Execute the app. and click on the commandbutton, enter the new name for the recycle bin and your PC will reset.

Then take a look at itīs new name!

~Iīve experienced that some API calls give an error under different versions of Windows.

If an error occurs in resetting your PC try:

t& = ExitWindowsEx (EWX_REBOOT, 0)

Shame on you Bill where is the backwards compatibility?!



Copyright © 1998-2007, The Team - Privacy statement
Did you find a bug on this page? Tell us!
This site is located at