Home > Backend Development > C++ > How to Easily Create Application Shortcuts in .NET using the ShellLink Class?

How to Easily Create Application Shortcuts in .NET using the ShellLink Class?

Susan Sarandon
Release: 2025-01-14 06:43:58
Original
482 people have browsed it

How to Easily Create Application Shortcuts in .NET using the ShellLink Class?

Streamlining Shortcut Creation in .NET using ShellLink

Generating application shortcuts in .NET isn't always intuitive. The ShellLink.cs class from vbAccelerator offers a streamlined approach, providing an elegant solution without relying on WSH.

Here's how to easily create a shortcut using ShellLink:

<code class="language-csharp">private static void configStep_addShortcutToStartupGroup()
{
    using (ShellLink shortcut = new ShellLink())
    {
        shortcut.Target = Application.ExecutablePath;
        shortcut.WorkingDirectory = Path.GetDirectoryName(Application.ExecutablePath);
        shortcut.Description = "My Shortcut Name Here";
        shortcut.DisplayMode = ShellLink.LinkDisplayMode.edmNormal;
        shortcut.Save(STARTUP_SHORTCUT_FILEPATH);
    }
}</code>
Copy after login

This concise code snippet creates and saves a shortcut, defining its target, working directory, description, and display mode. The ShellLink class simplifies the process, allowing for effortless shortcut creation in any specified location.

The above is the detailed content of How to Easily Create Application Shortcuts in .NET using the ShellLink Class?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template