2019-11-29-C # - Create a shortcut on the desktop Recycle Bin by programming methods

Original: 2019-11-29-C # - Create a shortcut on the desktop Recycle Bin by programming methods

title author date CreateTime categories
C # to create a shortcut on the desktop recycle bin by the method of programming
lindexi
2019-11-29 08:30:35 +0800
2019-3-19 9:12:4 +0800
C#

There will be all basic desktop shortcut to the Recycle Bin, if you want to create more than a few shortcuts that point to open the Recycle Bin, please see this article methods

After the Windows Script Host Object Model reference this COM methods can use the following code to create the desktop Recycle Bin.lnkshortcut, the shortcut to open the Recycle Bin

            object shDesktop = "Desktop";
            WshShell shell = new WshShell();
            string shortcutAddress = (string) shell.SpecialFolders.Item(ref shDesktop) + @"\Recycle Bin.lnk";
            IWshShortcut shortcut = (IWshShortcut) shell.CreateShortcut(shortcutAddress);
            shortcut.Description = "New shortcut for Recycle Bin";
            shortcut.Hotkey = "Ctrl+Shift+N";
            shortcut.IconLocation = @"C:\WINDOWS\System32\imageres.dll";
            shortcut.TargetPath = "::{645ff040-5081-101b-9f08-00aa002f954e}";
            shortcut.Save();

See using C # code to create a shortcut to the file - walterlv

C # how to reference the class WshShell

c# - Programmatically create a shortcut to the recycle bin or other special folders - Stack Overflow

Guess you like

Origin www.cnblogs.com/lonelyxmas/p/12075832.html