Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Dear All,

I'm creating windows application using c#, where i'm automating windows.

I'm trying to get the list of items in the start menu in windows 8.1. When we press only window key and we get some items on the start menu screen, i want to fetch these items only but not those which we get when we press "DownArrow" button on the bottom of the start menu screen.


Click here for more details

What I have tried:

C#
Environment.GetFolderPath(Environment.SpecialFolder.StartMenu);


I have tried above code but i'm getting those items which we get when we press "DownArrow" button on the bottom of the start menu screen.

But i'm looking for those items which we get when we press only window key.

Can anyone please help me.


Thanks in advance.
Posted
Updated 25-May-17 4:08am
v4

1 solution

See this article: C#: Get path of Start Menu programs (All USERS) - Programming (C#, C++, JAVA, VB, .NET etc.) - Neowin[^]
class Program
{
	[DllImport("shell32.dll")]
	static extern bool SHGetSpecialFolderPath(IntPtr hwndOwner, [Out] StringBuilder lpszPath, int nFolder, bool fCreate);
	const int CSIDL_COMMON_STARTMENU = 0x16;  // \Windows\Start Menu\Programs

	static void Main(string[] args)
	{
		StringBuilder path = new StringBuilder(260);
		SHGetSpecialFolderPath(IntPtr.Zero, path, CSIDL_COMMON_STARTMENU, false);
		string s = path.ToString();
	}
}
 
Share this answer
 
Comments
Richard Deeming 25-May-17 14:19pm    
No need for P/Invoke! :)
string s = Environment.GetFolderPath(Environment.SpecialFolder.CommonStartMenu);

GetFolderPath Method | Microsoft Docs[^]
RickZeeland 25-May-17 14:36pm    
No, it's needed because he wants a .NET 3.5 solution and CommonStartMenu was only added from .NET 4 :) :)
Richard Deeming 25-May-17 14:39pm    
Ah! I thought I must be missing something. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900