Shortcut in start menu

Mysterious_Dev 46 Reputation points
2022-06-11T07:20:44.243+00:00

Hi there ^^.

With the recent depreciation of UWP, I begin to learn how develop app with Windows APP SDK and I didn't found how add shortcut for my application in start menu (like on the screenshot).

210472-image.png

Is there someone know how I can do that or have a doc page for that with WASDK ?

Thanks in advance

Mysterious_Dev

Windows development | Windows App SDK
{count} votes

1 answer

Sort by: Most helpful
  1. Castorix31 90,686 Reputation points
    2022-06-11T10:32:36.177+00:00

    You can use the Shell.
    Test with a shortcut to Notepad :

                // Add reference to "Microsoft Shell Controls And Automation"  
                  
                string sLinkFile = @"\TestLink.lnk";  
                string sFullLinkFile = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu) + sLinkFile;  
                if (!System.IO.File.Exists(sFullLinkFile))  
                    System.IO.File.Create(sFullLinkFile).Dispose();                  
                Shell shell = new Shell();  
                Shell32.Folder folder = shell.NameSpace(new FileInfo(sFullLinkFile).Directory.FullName);  
                FolderItem fi = folder.ParseName(Path.GetFileName(sFullLinkFile));  
                ShellLinkObject link = (ShellLinkObject)fi.GetLink;  
                link.Path = @"C:\Windows\notepad.exe";  
                link.Description = "This is a test";  
                link.Save(sFullLinkFile);   
    

    210473-testlink.jpg

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.