mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-14 19:49:15 +08:00
30 lines
921 B
C#
30 lines
921 B
C#
using System;
|
|
using System.Runtime.InteropServices;
|
|
using System.Text;
|
|
|
|
namespace Wox.Plugin.Program.ProgramSources
|
|
{
|
|
[Serializable]
|
|
public sealed class CommonStartMenuProgramSource : FileSystemProgramSource
|
|
{
|
|
private const int CSIDL_COMMON_PROGRAMS = 0x17;
|
|
|
|
// todo happlebao how to pass location before loadPrograms
|
|
public CommonStartMenuProgramSource()
|
|
{
|
|
Location = getPath();
|
|
}
|
|
|
|
[DllImport("shell32.dll")]
|
|
private static extern bool SHGetSpecialFolderPath(IntPtr hwndOwner, [Out] StringBuilder lpszPath, int nFolder,
|
|
bool fCreate);
|
|
|
|
private static string getPath()
|
|
{
|
|
var commonStartMenuPath = new StringBuilder(560);
|
|
SHGetSpecialFolderPath(IntPtr.Zero, commonStartMenuPath, CSIDL_COMMON_PROGRAMS, false);
|
|
|
|
return commonStartMenuPath.ToString();
|
|
}
|
|
}
|
|
} |