Recycle Bin Context Menu


  • Hello!

    I have developped application which can add itself to Recycle Bin context menu. It works on WinXP.

    But on Vista not work

    I just want to add subkey to.


    Vista says: "There is no such key".

    OK. I'm trying to add this key:


    RegistryKey RecBinCLSID = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Classes\\CLSID\\{645FF040-5081-101B-9F08-00AA002F954E}", RegistryKeyPermissionCheck.ReadWriteSubTree, RegistryRights.FullControl);


    if (RecBinCLSID == null)

    throw new Exception("Can't access to:\n HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes\\CLSID\\{645FF040-5081-101B-9F08-00AA002F954E}");


    RecBinCLSID.CreateSubKey("Shell", RegistryKeyPermissionCheck.ReadWriteSubTree);


    And Vista says: "Access to the registry key '...\Shell' is denied."


    There is similair application. And seems that it can't access to this key to - CCleaner (just try to add it to Recycle Bin context menu - no effect).


    I prefer to use some API to do it. But I haven't found any.

    How can I add Recycle Bin context menu from my code?


    Best Regards.


    PS. Please note that manually I can create 'shell' subkey.

    Saturday, September 22, 2007 2:25 PM

All replies

  • Altering HKLM can only be done from an elevated process, since it causes a system-wide change. Have you tried creating the equivalent key under HKEY_CURRENT_USER? Since that is a per-user location it can be changed without elevation and has the added benefit that different users should be able to configure the setting differently.


    If it doesn't work under HKCU, then you'll either need to set it as part of your installation routine or use COM elevation to allow administrative users to temporarily elevate to change the setting.

    Monday, September 24, 2007 3:16 PM

    Thanks for your help.

    This problem resolved by adding <appname>.manifest file which tells Vista to run my program with administrative rights.




    Thursday, September 27, 2007 3:31 PM
  • Hello!!


    Can you please tell me how to create context menu for recycle bin??

    If possible please give sample.


    Best Regards,


    Wednesday, November 19, 2008 1:29 PM