1

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!

Carbongrip
  • 173
  • 1
  • 3
  • 12
  • 1
    What are you asking here? The start menu displays the contents of those folders in a specific way (on the "All Programs" and "pinned" lists). Nothing really special going on. Could you clarify your question? – BradleyDotNET Dec 13 '14 at 01:12
  • Sure I will try, in short I want to know how I myself can recreate the "pinned" and "All Programs" lists. – Carbongrip Dec 13 '14 at 05:19
  • Okay, it sounds like you already have the info you need. What are you missing? – BradleyDotNET Dec 13 '14 at 05:47
  • I don't exactly know how to implement this, I found what I stated above but find myself confused. Still not sure how I can make a list of pinned and all programs just like you see in start menu. Question is how I do that... sorry im confusing. I will make clear, how I make a start menu list. – Carbongrip Dec 13 '14 at 06:07
  • Also it appears they are checking both the users and global system start menu folders and displaying both "-" the duplicates. But still doesn't explain where the pins are coming from. – Carbongrip Dec 13 '14 at 06:56
  • 1
    You can get the pinned list from here: http://superuser.com/questions/171096/where-is-the-list-of-pinned-start-menu-and-taskbar-items-stored-in-windows-7 Stack overflow isn't for writing entire programs, could you be more specific as to what you are struggling with? – BradleyDotNET Dec 13 '14 at 18:02
  • Dude your awsome and have answered 50% of my question now. Now all I need to know is how I can get those shortcuts in a listbox that I can click to open app. Feel free to move your above comment with link to answers. Also please vote for my thread. – Carbongrip Dec 13 '14 at 18:14
  • 1
    This question is still very broad. I'll give you an upvote, because I'm on the fence, but try to reign in the scope of your questions a bit in the future. – BradleyDotNET Dec 15 '14 at 18:22

1 Answers1

2

To begin with, you can get the list of pinned programs for a user using:

%AppData%\Microsoft\Internet Explorer\Quick Launch\User Pinned\StartMenu

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.EnumerateFiles or Directory.GetFiles. Once you have the list of files, you'll need to create ViewModel objects for each of them:

public class StartMenuItem
{
    public Image Icon {get; set;}
    public String LinkPath {get; set;}
}

Create a collection of these and bind your list view ItemSource to it. Finally, to start the application, you can just use Process.Start:

ProcessStartInfo info = new ProcessStartInfo ( "example.lnk" );
info.CreateNoWindow = true;
info.RedirectStandardError = true;
info.RedirectStandardOutput = true;
info.RedirectStandardInput = true;
Process whatever = Process.Start( info );

See Run application via shortcut using Process.Start C# for more information.

Community
  • 1
  • 1
BradleyDotNET
  • 60,462
  • 10
  • 96
  • 117
  • 1
    Note, I did not post the `DataTemplate` as my answer was already pretty long. If you have a question about how to bind to images in a template, or how to set up the command to run the `Process.Start`, I would ask another question about that piece. – BradleyDotNET Dec 15 '14 at 18:20
  • Thank You! This is just what I needed I will make a thread if I need more help with process.start but think I understand it. – Carbongrip Dec 15 '14 at 22:41