Hey everyone I am working on a start menu style program and would like to know how I get pinned programs and all programs list. I started some research and will post what I found so you can all help fill the gaps.
For getting program icons I found this...
public static Icon IconFromFilePath(string filePath)
{
var result = (Icon)null;
try
{
result = Icon.ExtractAssociatedIcon(filePath);
}
catch (System.Exception)
{
// swallow and return nothing. You could supply a default Icon here as well
}
return result;
}
For getting all programs and pinned programs I find these paths...
%USERPROFILE%\appdata\Roaming\Microsoft\Windows\Start Menu\Programs
C:\ProgramData\Microsoft\Windows\Start Menu\
What are these locations and how does the startmenu utlise these? How can I use them? Hope I am not being to brief but wanted to show I am really working to solve this problem and have been searching a ton. Thanks!
To begin with, you can get the list of pinned programs for a user using:
Credit to https://superuser.com/a/171129
Both that folder, and the ones you already found, contain all the shortcuts for the Start Menu. You can get the files using
Directory.EnumerateFilesorDirectory.GetFiles. Once you have the list of files, you'll need to create ViewModel objects for each of them:Create a collection of these and bind your list view
ItemSourceto it. Finally, to start the application, you can just useProcess.Start:See Run application via shortcut using Process.Start C# for more information.