mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 12:18:50 +02:00
Whitespace and type fixes (#5917)
This commit is contained in:
@@ -57,6 +57,7 @@ namespace Microsoft.Plugin.Program
|
|||||||
System.Windows.MessageBox.Show(_context.API.GetTranslation("wox_plugin_program_invalid_path"));
|
System.Windows.MessageBox.Show(_context.API.GetTranslation("wox_plugin_program_invalid_path"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_editing == null)
|
if (_editing == null)
|
||||||
{
|
{
|
||||||
if (!ProgramSetting.ProgramSettingDisplayList.Any(x => x.UniqueIdentifier == Directory.Text))
|
if (!ProgramSetting.ProgramSettingDisplayList.Any(x => x.UniqueIdentifier == Directory.Text))
|
||||||
|
|||||||
@@ -40,9 +40,10 @@ namespace Microsoft.Plugin.Program.Logger
|
|||||||
var rule = new LoggingRule("*", LogLevel.Debug, target);
|
var rule = new LoggingRule("*", LogLevel.Debug, target);
|
||||||
#else
|
#else
|
||||||
var rule = new LoggingRule("*", LogLevel.Error, target);
|
var rule = new LoggingRule("*", LogLevel.Error, target);
|
||||||
#endif
|
#endif
|
||||||
configuration.LoggingRules.Add(rule);
|
configuration.LoggingRules.Add(rule);
|
||||||
}
|
}
|
||||||
|
|
||||||
LogManager.Configuration = configuration;
|
LogManager.Configuration = configuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,7 +56,7 @@ namespace Microsoft.Plugin.Program.Logger
|
|||||||
{
|
{
|
||||||
Debug.WriteLine($"ERROR{classname}|{callingMethodName}|{loadingProgramPath}|{interpretationMessage}");
|
Debug.WriteLine($"ERROR{classname}|{callingMethodName}|{loadingProgramPath}|{interpretationMessage}");
|
||||||
|
|
||||||
var logger = LogManager.GetLogger("");
|
var logger = LogManager.GetLogger(string.Empty);
|
||||||
|
|
||||||
var innerExceptionNumber = 1;
|
var innerExceptionNumber = 1;
|
||||||
|
|
||||||
@@ -102,11 +103,11 @@ namespace Microsoft.Plugin.Program.Logger
|
|||||||
[MethodImpl(MethodImplOptions.Synchronized)]
|
[MethodImpl(MethodImplOptions.Synchronized)]
|
||||||
internal static void LogException(string message, Exception e)
|
internal static void LogException(string message, Exception e)
|
||||||
{
|
{
|
||||||
//Index 0 is always empty.
|
// Index 0 is always empty.
|
||||||
var parts = message.Split('|');
|
var parts = message.Split('|');
|
||||||
if (parts.Length < 4)
|
if (parts.Length < 4)
|
||||||
{
|
{
|
||||||
var logger = LogManager.GetLogger("");
|
var logger = LogManager.GetLogger(string.Empty);
|
||||||
logger.Error(e, $"fail to log exception in program logger, parts length is too small: {parts.Length}, message: {message}");
|
logger.Error(e, $"fail to log exception in program logger, parts length is too small: {parts.Length}, message: {message}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ namespace Microsoft.Plugin.Program
|
|||||||
{
|
{
|
||||||
_settingsStorage = new PluginJsonStorage<ProgramPluginSettings>();
|
_settingsStorage = new PluginJsonStorage<ProgramPluginSettings>();
|
||||||
_settings = _settingsStorage.Load();
|
_settings = _settingsStorage.Load();
|
||||||
|
|
||||||
// This helper class initializes the file system watchers based on the locations to watch
|
// This helper class initializes the file system watchers based on the locations to watch
|
||||||
_win32ProgramRepositoryHelper = new Win32ProgramFileSystemWatchers();
|
_win32ProgramRepositoryHelper = new Win32ProgramFileSystemWatchers();
|
||||||
|
|
||||||
@@ -63,7 +64,6 @@ namespace Microsoft.Plugin.Program
|
|||||||
Task.WaitAll(a, b);
|
Task.WaitAll(a, b);
|
||||||
|
|
||||||
_settings.LastIndexTime = DateTime.Today;
|
_settings.LastIndexTime = DateTime.Today;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Save()
|
public void Save()
|
||||||
@@ -132,7 +132,7 @@ namespace Microsoft.Plugin.Program
|
|||||||
|
|
||||||
public List<ContextMenuResult> LoadContextMenus(Result selectedResult)
|
public List<ContextMenuResult> LoadContextMenus(Result selectedResult)
|
||||||
{
|
{
|
||||||
if(selectedResult == null)
|
if (selectedResult == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(selectedResult));
|
throw new ArgumentNullException(nameof(selectedResult));
|
||||||
}
|
}
|
||||||
@@ -152,12 +152,12 @@ namespace Microsoft.Plugin.Program
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if(runProcess == null)
|
if (runProcess == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(runProcess));
|
throw new ArgumentNullException(nameof(runProcess));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(info == null)
|
if (info == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(info));
|
throw new ArgumentNullException(nameof(info));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,11 +12,11 @@ namespace Microsoft.Plugin.Program
|
|||||||
{
|
{
|
||||||
public DateTime LastIndexTime { get; set; }
|
public DateTime LastIndexTime { get; set; }
|
||||||
|
|
||||||
public List<ProgramSource> ProgramSources { get;} = new List<ProgramSource>();
|
public List<ProgramSource> ProgramSources { get; } = new List<ProgramSource>();
|
||||||
|
|
||||||
public List<DisabledProgramSource> DisabledProgramSources { get;} = new List<DisabledProgramSource>();
|
public List<DisabledProgramSource> DisabledProgramSources { get; } = new List<DisabledProgramSource>();
|
||||||
|
|
||||||
public List<string> ProgramSuffixes { get; } = new List<string>(){ "bat", "appref-ms", "exe", "lnk", "url" };
|
public List<string> ProgramSuffixes { get; } = new List<string>() { "bat", "appref-ms", "exe", "lnk", "url" };
|
||||||
|
|
||||||
public bool EnableStartMenuSource { get; set; } = true;
|
public bool EnableStartMenuSource { get; set; } = true;
|
||||||
|
|
||||||
@@ -29,7 +29,6 @@ namespace Microsoft.Plugin.Program
|
|||||||
public double MinScoreThreshold { get; set; } = 0.75;
|
public double MinScoreThreshold { get; set; } = 0.75;
|
||||||
|
|
||||||
internal const char SuffixSeparator = ';';
|
internal const char SuffixSeparator = ';';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ using System.Runtime.InteropServices;
|
|||||||
namespace Microsoft.Plugin.Program.Programs.ApplicationActivationHelper
|
namespace Microsoft.Plugin.Program.Programs.ApplicationActivationHelper
|
||||||
{
|
{
|
||||||
// Reference : https://github.com/MicrosoftEdge/edge-launcher/blob/108e63df0b4cb5cd9d5e45aa7a264690851ec51d/MIcrosoftEdgeLauncherCsharp/Program.cs
|
// Reference : https://github.com/MicrosoftEdge/edge-launcher/blob/108e63df0b4cb5cd9d5e45aa7a264690851ec51d/MIcrosoftEdgeLauncherCsharp/Program.cs
|
||||||
[Flags()]
|
[Flags]
|
||||||
public enum ActivateOptions
|
public enum ActivateOptions
|
||||||
{
|
{
|
||||||
None = 0x00000000,
|
None = 0x00000000,
|
||||||
@@ -18,29 +18,32 @@ namespace Microsoft.Plugin.Program.Programs.ApplicationActivationHelper
|
|||||||
NoSplashScreen = 0x00000004,
|
NoSplashScreen = 0x00000004,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ApplicationActivationManager
|
// ApplicationActivationManager
|
||||||
[ComImport, Guid("2e941141-7f97-4756-ba1d-9decde894a3d"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
[ComImport]
|
||||||
|
[Guid("2e941141-7f97-4756-ba1d-9decde894a3d")]
|
||||||
|
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||||
public interface IApplicationActivationManager
|
public interface IApplicationActivationManager
|
||||||
{
|
{
|
||||||
IntPtr ActivateApplication([In] String appUserModelId, [In] String arguments, [In] ActivateOptions options, [Out] out UInt32 processId);
|
IntPtr ActivateApplication([In] string appUserModelId, [In] string arguments, [In] ActivateOptions options, [Out] out uint processId);
|
||||||
|
|
||||||
IntPtr ActivateForFile([In] String appUserModelId, [In] IntPtr /*IShellItemArray* */ itemArray, [In] String verb, [Out] out UInt32 processId);
|
IntPtr ActivateForFile([In] string appUserModelId, [In] IntPtr /*IShellItemArray* */ itemArray, [In] string verb, [Out] out uint processId);
|
||||||
|
|
||||||
IntPtr ActivateForProtocol([In] String appUserModelId, [In] IntPtr /* IShellItemArray* */itemArray, [Out] out UInt32 processId);
|
IntPtr ActivateForProtocol([In] string appUserModelId, [In] IntPtr /* IShellItemArray* */itemArray, [Out] out uint processId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Application Activation Manager Class
|
// Application Activation Manager Class
|
||||||
[ComImport, Guid("45BA127D-10A8-46EA-8AB7-56EA9078943C")]
|
[ComImport]
|
||||||
|
[Guid("45BA127D-10A8-46EA-8AB7-56EA9078943C")]
|
||||||
public class ApplicationActivationManager : IApplicationActivationManager
|
public class ApplicationActivationManager : IApplicationActivationManager
|
||||||
{
|
{
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)/*, PreserveSig*/]
|
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)/*, PreserveSig*/]
|
||||||
public extern IntPtr ActivateApplication([In] String appUserModelId, [In] String arguments, [In] ActivateOptions options, [Out] out UInt32 processId);
|
public extern IntPtr ActivateApplication([In] string appUserModelId, [In] string arguments, [In] ActivateOptions options, [Out] out uint processId);
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
|
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
|
||||||
public extern IntPtr ActivateForFile([In] String appUserModelId, [In] IntPtr /*IShellItemArray* */ itemArray, [In] String verb, [Out] out UInt32 processId);
|
public extern IntPtr ActivateForFile([In] string appUserModelId, [In] IntPtr /*IShellItemArray* */ itemArray, [In] string verb, [Out] out uint processId);
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
|
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
|
||||||
public extern IntPtr ActivateForProtocol([In] String appUserModelId, [In] IntPtr /* IShellItemArray* */itemArray, [Out] out UInt32 processId);
|
public extern IntPtr ActivateForProtocol([In] string appUserModelId, [In] IntPtr /* IShellItemArray* */itemArray, [Out] out uint processId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,8 +28,10 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
{
|
{
|
||||||
apps.Add(manifestApp);
|
apps.Add(manifestApp);
|
||||||
}
|
}
|
||||||
|
|
||||||
manifestApps.MoveNext();
|
manifestApps.MoveNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
return apps;
|
return apps;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,17 +41,20 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
{
|
{
|
||||||
Marshal.ThrowExceptionForHR((int)hr);
|
Marshal.ThrowExceptionForHR((int)hr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reference : https://stackoverflow.com/questions/32122679/getting-icon-of-modern-windows-app-from-a-desktop-application
|
// Reference : https://stackoverflow.com/questions/32122679/getting-icon-of-modern-windows-app-from-a-desktop-application
|
||||||
[Guid("5842a140-ff9f-4166-8f5c-62f5b7b0c781"), ComImport]
|
[Guid("5842a140-ff9f-4166-8f5c-62f5b7b0c781")]
|
||||||
|
[ComImport]
|
||||||
public class AppxFactory
|
public class AppxFactory
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
[Guid("BEB94909-E451-438B-B5A7-D79E767B75D8"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
[Guid("BEB94909-E451-438B-B5A7-D79E767B75D8")]
|
||||||
|
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||||
public interface IAppxFactory
|
public interface IAppxFactory
|
||||||
{
|
{
|
||||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1707:Identifiers should not contain underscores", Justification = "Implements COM Interface")]
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1707:Identifiers should not contain underscores", Justification = "Implements COM Interface")]
|
||||||
@@ -58,7 +63,8 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
IAppxManifestReader CreateManifestReader(IStream inputStream);
|
IAppxManifestReader CreateManifestReader(IStream inputStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Guid("4E1BD148-55A0-4480-A3D1-15544710637C"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
[Guid("4E1BD148-55A0-4480-A3D1-15544710637C")]
|
||||||
|
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||||
public interface IAppxManifestReader
|
public interface IAppxManifestReader
|
||||||
{
|
{
|
||||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1707:Identifiers should not contain underscores", Justification = "Implements COM Interface")]
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1707:Identifiers should not contain underscores", Justification = "Implements COM Interface")]
|
||||||
@@ -72,7 +78,8 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
IAppxManifestApplicationsEnumerator GetApplications();
|
IAppxManifestApplicationsEnumerator GetApplications();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Guid("9EB8A55A-F04B-4D0D-808D-686185D4847A"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
[Guid("9EB8A55A-F04B-4D0D-808D-686185D4847A")]
|
||||||
|
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||||
public interface IAppxManifestApplicationsEnumerator
|
public interface IAppxManifestApplicationsEnumerator
|
||||||
{
|
{
|
||||||
IAppxManifestApplication GetCurrent();
|
IAppxManifestApplication GetCurrent();
|
||||||
@@ -82,7 +89,8 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
bool MoveNext();
|
bool MoveNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Guid("5DA89BF4-3773-46BE-B650-7E744863B7E8"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
[Guid("5DA89BF4-3773-46BE-B650-7E744863B7E8")]
|
||||||
|
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||||
public interface IAppxManifestApplication
|
public interface IAppxManifestApplication
|
||||||
{
|
{
|
||||||
[PreserveSig]
|
[PreserveSig]
|
||||||
@@ -92,7 +100,8 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
Hresult GetAppUserModelId([MarshalAs(UnmanagedType.LPWStr)] out string value);
|
Hresult GetAppUserModelId([MarshalAs(UnmanagedType.LPWStr)] out string value);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Guid("03FAF64D-F26F-4B2C-AAF7-8FE7789B8BCA"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
[Guid("03FAF64D-F26F-4B2C-AAF7-8FE7789B8BCA")]
|
||||||
|
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||||
public interface IAppxManifestProperties
|
public interface IAppxManifestProperties
|
||||||
{
|
{
|
||||||
[PreserveSig]
|
[PreserveSig]
|
||||||
|
|||||||
@@ -13,6 +13,5 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
string Arguments { get; set; }
|
string Arguments { get; set; }
|
||||||
|
|
||||||
bool hasArguments { get; set; }
|
bool hasArguments { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,13 +17,11 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
|
|
||||||
public PackageCatalogWrapper()
|
public PackageCatalogWrapper()
|
||||||
{
|
{
|
||||||
//Opens the catalog of packages that is available for the current user.
|
// Opens the catalog of packages that is available for the current user.
|
||||||
_packageCatalog = PackageCatalog.OpenForCurrentUser();
|
_packageCatalog = PackageCatalog.OpenForCurrentUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
// Summary: Indicates that an app package is installing.
|
||||||
// Summary:
|
|
||||||
// Indicates that an app package is installing.
|
|
||||||
public event TypedEventHandler<PackageCatalog, PackageInstallingEventArgs> PackageInstalling
|
public event TypedEventHandler<PackageCatalog, PackageInstallingEventArgs> PackageInstalling
|
||||||
{
|
{
|
||||||
add
|
add
|
||||||
@@ -37,9 +35,7 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
// Summary: Indicates that an app package is uninstalling.
|
||||||
// Summary:
|
|
||||||
// Indicates that an app package is uninstalling.
|
|
||||||
public event TypedEventHandler<PackageCatalog, PackageUninstallingEventArgs> PackageUninstalling
|
public event TypedEventHandler<PackageCatalog, PackageUninstallingEventArgs> PackageUninstalling
|
||||||
{
|
{
|
||||||
add
|
add
|
||||||
@@ -53,9 +49,7 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
// Summary: Indicates that an app package is updating.
|
||||||
// Summary:
|
|
||||||
// Indicates that an app package is updating.
|
|
||||||
public event TypedEventHandler<PackageCatalog, PackageUpdatingEventArgs> PackageUpdating
|
public event TypedEventHandler<PackageCatalog, PackageUpdatingEventArgs> PackageUpdating
|
||||||
{
|
{
|
||||||
add
|
add
|
||||||
@@ -68,6 +62,5 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
_packageCatalog.PackageUpdating -= value;
|
_packageCatalog.PackageUpdating -= value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
|
|
||||||
public static PackageWrapper GetWrapperFromPackage(Package package)
|
public static PackageWrapper GetWrapperFromPackage(Package package)
|
||||||
{
|
{
|
||||||
if(package == null)
|
if (package == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(package));
|
throw new ArgumentNullException(nameof(package));
|
||||||
}
|
}
|
||||||
@@ -55,7 +55,7 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
package.Id.FullName,
|
package.Id.FullName,
|
||||||
package.Id.FamilyName,
|
package.Id.FamilyName,
|
||||||
package.IsFramework,
|
package.IsFramework,
|
||||||
package.IsDevelopmentMode,
|
package.IsDevelopmentMode,
|
||||||
string.Empty);
|
string.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,7 +67,6 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
package.IsDevelopmentMode,
|
package.IsDevelopmentMode,
|
||||||
path
|
path
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
{
|
{
|
||||||
public class ShellLinkHelper : IShellLinkHelper
|
public class ShellLinkHelper : IShellLinkHelper
|
||||||
{
|
{
|
||||||
[Flags()]
|
[Flags]
|
||||||
private enum SLGP_FLAGS
|
private enum SLGP_FLAGS
|
||||||
{
|
{
|
||||||
SLGP_SHORTPATH = 0x1,
|
SLGP_SHORTPATH = 0x1,
|
||||||
@@ -38,7 +38,7 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
public string cAlternateFileName;
|
public string cAlternateFileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Flags()]
|
[Flags]
|
||||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1707:Identifiers should not contain underscores", Justification = "Represents flags specified in IShellLink interface")]
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1707:Identifiers should not contain underscores", Justification = "Represents flags specified in IShellLink interface")]
|
||||||
public enum SLR_FLAGS
|
public enum SLR_FLAGS
|
||||||
{
|
{
|
||||||
@@ -53,59 +53,79 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Reference : http://www.pinvoke.net/default.aspx/Interfaces.IShellLinkW
|
// Reference : http://www.pinvoke.net/default.aspx/Interfaces.IShellLinkW
|
||||||
/// The IShellLink interface allows Shell links to be created, modified, and resolved
|
|
||||||
[ComImport(), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("000214F9-0000-0000-C000-000000000046")]
|
// The IShellLink interface allows Shell links to be created, modified, and resolved
|
||||||
|
[ComImport]
|
||||||
|
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||||
|
[Guid("000214F9-0000-0000-C000-000000000046")]
|
||||||
interface IShellLinkW
|
interface IShellLinkW
|
||||||
{
|
{
|
||||||
/// <summary>Retrieves the path and file name of a Shell link object</summary>
|
/// <summary>Retrieves the path and file name of a Shell link object</summary>
|
||||||
void GetPath([Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszFile, int cchMaxPath, ref WIN32_FIND_DATAW pfd, SLGP_FLAGS fFlags);
|
void GetPath([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszFile, int cchMaxPath, ref WIN32_FIND_DATAW pfd, SLGP_FLAGS fFlags);
|
||||||
|
|
||||||
/// <summary>Retrieves the list of item identifiers for a Shell link object</summary>
|
/// <summary>Retrieves the list of item identifiers for a Shell link object</summary>
|
||||||
void GetIDList(out IntPtr ppidl);
|
void GetIDList(out IntPtr ppidl);
|
||||||
|
|
||||||
/// <summary>Sets the pointer to an item identifier list (PIDL) for a Shell link object.</summary>
|
/// <summary>Sets the pointer to an item identifier list (PIDL) for a Shell link object.</summary>
|
||||||
void SetIDList(IntPtr pidl);
|
void SetIDList(IntPtr pidl);
|
||||||
|
|
||||||
/// <summary>Retrieves the description string for a Shell link object</summary>
|
/// <summary>Retrieves the description string for a Shell link object</summary>
|
||||||
void GetDescription([Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszName, int cchMaxName);
|
void GetDescription([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszName, int cchMaxName);
|
||||||
|
|
||||||
/// <summary>Sets the description for a Shell link object. The description can be any application-defined string</summary>
|
/// <summary>Sets the description for a Shell link object. The description can be any application-defined string</summary>
|
||||||
void SetDescription([MarshalAs(UnmanagedType.LPWStr)] string pszName);
|
void SetDescription([MarshalAs(UnmanagedType.LPWStr)] string pszName);
|
||||||
|
|
||||||
/// <summary>Retrieves the name of the working directory for a Shell link object</summary>
|
/// <summary>Retrieves the name of the working directory for a Shell link object</summary>
|
||||||
void GetWorkingDirectory([Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszDir, int cchMaxPath);
|
void GetWorkingDirectory([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszDir, int cchMaxPath);
|
||||||
|
|
||||||
/// <summary>Sets the name of the working directory for a Shell link object</summary>
|
/// <summary>Sets the name of the working directory for a Shell link object</summary>
|
||||||
void SetWorkingDirectory([MarshalAs(UnmanagedType.LPWStr)] string pszDir);
|
void SetWorkingDirectory([MarshalAs(UnmanagedType.LPWStr)] string pszDir);
|
||||||
|
|
||||||
/// <summary>Retrieves the command-line arguments associated with a Shell link object</summary>
|
/// <summary>Retrieves the command-line arguments associated with a Shell link object</summary>
|
||||||
void GetArguments([Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszArgs, int cchMaxPath);
|
void GetArguments([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszArgs, int cchMaxPath);
|
||||||
|
|
||||||
/// <summary>Sets the command-line arguments for a Shell link object</summary>
|
/// <summary>Sets the command-line arguments for a Shell link object</summary>
|
||||||
void SetArguments([MarshalAs(UnmanagedType.LPWStr)] string pszArgs);
|
void SetArguments([MarshalAs(UnmanagedType.LPWStr)] string pszArgs);
|
||||||
|
|
||||||
/// <summary>Retrieves the hot key for a Shell link object</summary>
|
/// <summary>Retrieves the hot key for a Shell link object</summary>
|
||||||
void GetHotkey(out short pwHotkey);
|
void GetHotkey(out short pwHotkey);
|
||||||
|
|
||||||
/// <summary>Sets a hot key for a Shell link object</summary>
|
/// <summary>Sets a hot key for a Shell link object</summary>
|
||||||
void SetHotkey(short wHotkey);
|
void SetHotkey(short wHotkey);
|
||||||
|
|
||||||
/// <summary>Retrieves the show command for a Shell link object</summary>
|
/// <summary>Retrieves the show command for a Shell link object</summary>
|
||||||
void GetShowCmd(out int piShowCmd);
|
void GetShowCmd(out int piShowCmd);
|
||||||
|
|
||||||
/// <summary>Sets the show command for a Shell link object. The show command sets the initial show state of the window.</summary>
|
/// <summary>Sets the show command for a Shell link object. The show command sets the initial show state of the window.</summary>
|
||||||
void SetShowCmd(int iShowCmd);
|
void SetShowCmd(int iShowCmd);
|
||||||
|
|
||||||
/// <summary>Retrieves the location (path and index) of the icon for a Shell link object</summary>
|
/// <summary>Retrieves the location (path and index) of the icon for a Shell link object</summary>
|
||||||
void GetIconLocation([Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszIconPath,
|
void GetIconLocation([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszIconPath, int cchIconPath, out int piIcon);
|
||||||
int cchIconPath, out int piIcon);
|
|
||||||
/// <summary>Sets the location (path and index) of the icon for a Shell link object</summary>
|
/// <summary>Sets the location (path and index) of the icon for a Shell link object</summary>
|
||||||
void SetIconLocation([MarshalAs(UnmanagedType.LPWStr)] string pszIconPath, int iIcon);
|
void SetIconLocation([MarshalAs(UnmanagedType.LPWStr)] string pszIconPath, int iIcon);
|
||||||
|
|
||||||
/// <summary>Sets the relative path to the Shell link object</summary>
|
/// <summary>Sets the relative path to the Shell link object</summary>
|
||||||
void SetRelativePath([MarshalAs(UnmanagedType.LPWStr)] string pszPathRel, int dwReserved);
|
void SetRelativePath([MarshalAs(UnmanagedType.LPWStr)] string pszPathRel, int dwReserved);
|
||||||
|
|
||||||
/// <summary>Attempts to find the target of a Shell link, even if it has been moved or renamed</summary>
|
/// <summary>Attempts to find the target of a Shell link, even if it has been moved or renamed</summary>
|
||||||
void Resolve(ref Accessibility._RemotableHandle hwnd, SLR_FLAGS fFlags);
|
void Resolve(ref Accessibility._RemotableHandle hwnd, SLR_FLAGS fFlags);
|
||||||
|
|
||||||
/// <summary>Sets the path and file name of a Shell link object</summary>
|
/// <summary>Sets the path and file name of a Shell link object</summary>
|
||||||
void SetPath([MarshalAs(UnmanagedType.LPWStr)] string pszFile);
|
void SetPath([MarshalAs(UnmanagedType.LPWStr)] string pszFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
[ComImport(), Guid("00021401-0000-0000-C000-000000000046")]
|
[ComImport]
|
||||||
|
[Guid("00021401-0000-0000-C000-000000000046")]
|
||||||
private class ShellLink
|
private class ShellLink
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// Contains the description of the app
|
// Contains the description of the app
|
||||||
public string description { get; set; } = String.Empty;
|
public string description { get; set; } = string.Empty;
|
||||||
|
|
||||||
// Contains the arguments to the app
|
// Contains the arguments to the app
|
||||||
public string Arguments { get; set; } = String.Empty;
|
public string Arguments { get; set; } = string.Empty;
|
||||||
|
|
||||||
public bool hasArguments { get; set; } = false;
|
public bool hasArguments { get; set; } = false;
|
||||||
|
|
||||||
@@ -122,21 +142,21 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
catch (System.IO.FileNotFoundException ex)
|
catch (System.IO.FileNotFoundException ex)
|
||||||
{
|
{
|
||||||
ProgramLogger.LogException($"|Win32| ShellLinkHelper.retrieveTargetPath | {path} | Path could not be retrieved", ex);
|
ProgramLogger.LogException($"|Win32| ShellLinkHelper.retrieveTargetPath | {path} | Path could not be retrieved", ex);
|
||||||
return String.Empty;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
var hwnd = new _RemotableHandle();
|
var hwnd = default(_RemotableHandle);
|
||||||
((IShellLinkW)link).Resolve(ref hwnd, 0);
|
((IShellLinkW)link).Resolve(ref hwnd, 0);
|
||||||
|
|
||||||
const int MAX_PATH = 260;
|
const int MAX_PATH = 260;
|
||||||
StringBuilder buffer = new StringBuilder(MAX_PATH);
|
StringBuilder buffer = new StringBuilder(MAX_PATH);
|
||||||
|
|
||||||
var data = new WIN32_FIND_DATAW();
|
var data = default(WIN32_FIND_DATAW);
|
||||||
((IShellLinkW)link).GetPath(buffer, buffer.Capacity, ref data, SLGP_FLAGS.SLGP_SHORTPATH);
|
((IShellLinkW)link).GetPath(buffer, buffer.Capacity, ref data, SLGP_FLAGS.SLGP_SHORTPATH);
|
||||||
var target = buffer.ToString();
|
var target = buffer.ToString();
|
||||||
|
|
||||||
// To set the app description
|
// To set the app description
|
||||||
if (!String.IsNullOrEmpty(target))
|
if (!string.IsNullOrEmpty(target))
|
||||||
{
|
{
|
||||||
buffer = new StringBuilder(MAX_PATH);
|
buffer = new StringBuilder(MAX_PATH);
|
||||||
((IShellLinkW)link).GetDescription(buffer, MAX_PATH);
|
((IShellLinkW)link).GetDescription(buffer, MAX_PATH);
|
||||||
@@ -152,6 +172,7 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
hasArguments = true;
|
hasArguments = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,14 +81,15 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
var e = Marshal.GetExceptionForHR((int)hResult);
|
var e = Marshal.GetExceptionForHR((int)hResult);
|
||||||
ProgramLogger.LogException($"|UWP|InitializeAppInfo|{path}" +
|
ProgramLogger.LogException(
|
||||||
|
$"|UWP|InitializeAppInfo|{path}" +
|
||||||
"|Error caused while trying to get the details of the UWP program", e);
|
"|Error caused while trying to get the details of the UWP program", e);
|
||||||
|
|
||||||
Apps = new List<UWPApplication>().ToArray();
|
Apps = new List<UWPApplication>().ToArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// http://www.hanselman.com/blog/GetNamespacesFromAnXMLDocumentWithXPathDocumentAndLINQToXML.aspx
|
// http://www.hanselman.com/blog/GetNamespacesFromAnXMLDocumentWithXPathDocumentAndLINQToXML.aspx
|
||||||
private static string[] XmlNamespaces(string path)
|
private static string[] XmlNamespaces(string path)
|
||||||
{
|
{
|
||||||
XDocument z = XDocument.Load(path);
|
XDocument z = XDocument.Load(path);
|
||||||
@@ -130,7 +131,8 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ProgramLogger.LogException($"|UWP|XmlNamespaces|{Location}" +
|
ProgramLogger.LogException(
|
||||||
|
$"|UWP|XmlNamespaces|{Location}" +
|
||||||
"|Trying to get the package version of the UWP program, but a unknown UWP appmanifest version "
|
"|Trying to get the package version of the UWP program, but a unknown UWP appmanifest version "
|
||||||
+ $"{FullName} from location {Location} is returned.", new FormatException());
|
+ $"{FullName} from location {Location} is returned.", new FormatException());
|
||||||
|
|
||||||
@@ -154,10 +156,12 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
ProgramLogger.LogException($"|UWP|All|{p.InstalledLocation}|An unexpected error occurred and "
|
ProgramLogger.LogException(
|
||||||
|
$"|UWP|All|{p.InstalledLocation}|An unexpected error occurred and "
|
||||||
+ $"unable to convert Package to UWP for {p.FullName}", e);
|
+ $"unable to convert Package to UWP for {p.FullName}", e);
|
||||||
return Array.Empty<UWPApplication>();
|
return Array.Empty<UWPApplication>();
|
||||||
}
|
}
|
||||||
|
|
||||||
return u.Apps;
|
return u.Apps;
|
||||||
}).ToArray();
|
}).ToArray();
|
||||||
|
|
||||||
@@ -189,8 +193,7 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
ProgramLogger.LogException("UWP", "CurrentUserPackages", $"id", "An unexpected error occurred and "
|
ProgramLogger.LogException("UWP", "CurrentUserPackages", $"id", "An unexpected error occurred and unable to verify if package is valid", e);
|
||||||
+ $"unable to verify if package is valid", e);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,15 +235,14 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
|
|
||||||
[Flags]
|
[Flags]
|
||||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1714:Flags enums should have plural names", Justification = "This name is consistent with the corresponding win32 flags: https://docs.microsoft.com/en-us/windows/win32/stg/stgm-constants ")]
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1714:Flags enums should have plural names", Justification = "This name is consistent with the corresponding win32 flags: https://docs.microsoft.com/en-us/windows/win32/stg/stgm-constants ")]
|
||||||
public enum Stgm : Int64
|
public enum Stgm : long
|
||||||
{
|
{
|
||||||
Read = 0x00000000L,
|
Read = 0x00000000L,
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Hresult : Int32
|
public enum Hresult : int
|
||||||
{
|
{
|
||||||
Ok = 0x0,
|
Ok = 0x0,
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -145,6 +145,7 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
contextMenus.Add(
|
contextMenus.Add(
|
||||||
new ContextMenuResult
|
new ContextMenuResult
|
||||||
{
|
{
|
||||||
@@ -263,6 +264,7 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -305,7 +307,8 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ProgramLogger.LogException($"|UWP|ResourceFromPri|{Package.Location}|Can't load null or empty result "
|
ProgramLogger.LogException(
|
||||||
|
$"|UWP|ResourceFromPri|{Package.Location}|Can't load null or empty result "
|
||||||
+ $"pri {source} in uwp location {Package.Location}", new NullReferenceException());
|
+ $"pri {source} in uwp location {Package.Location}", new NullReferenceException());
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
@@ -368,7 +371,6 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
// windows 10 https://msdn.microsoft.com/en-us/library/windows/apps/dn934817.aspx
|
// windows 10 https://msdn.microsoft.com/en-us/library/windows/apps/dn934817.aspx
|
||||||
// windows 8.1 https://msdn.microsoft.com/en-us/library/windows/apps/hh965372.aspx#target_size
|
// windows 8.1 https://msdn.microsoft.com/en-us/library/windows/apps/hh965372.aspx#target_size
|
||||||
// windows 8 https://msdn.microsoft.com/en-us/library/windows/apps/br211475.aspx
|
// windows 8 https://msdn.microsoft.com/en-us/library/windows/apps/br211475.aspx
|
||||||
|
|
||||||
string path;
|
string path;
|
||||||
if (uri.Contains("\\", StringComparison.Ordinal))
|
if (uri.Contains("\\", StringComparison.Ordinal))
|
||||||
{
|
{
|
||||||
@@ -440,7 +442,8 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ProgramLogger.LogException($"|UWP|LogoPathFromUri|{Package.Location}" +
|
ProgramLogger.LogException(
|
||||||
|
$"|UWP|LogoPathFromUri|{Package.Location}" +
|
||||||
$"|{UserModelId} can't find logo uri for {uri} in package location: {Package.Location}", new FileNotFoundException());
|
$"|{UserModelId} can't find logo uri for {uri} in package location: {Package.Location}", new FileNotFoundException());
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
@@ -448,7 +451,8 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ProgramLogger.LogException($"|UWP|LogoPathFromUri|{Package.Location}" +
|
ProgramLogger.LogException(
|
||||||
|
$"|UWP|LogoPathFromUri|{Package.Location}" +
|
||||||
$"|Unable to find extension from {uri} for {UserModelId} " +
|
$"|Unable to find extension from {uri} for {UserModelId} " +
|
||||||
$"in package location {Package.Location}", new FileNotFoundException());
|
$"in package location {Package.Location}", new FileNotFoundException());
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
@@ -479,7 +483,8 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ProgramLogger.LogException($"|UWP|ImageFromPath|{path}" +
|
ProgramLogger.LogException(
|
||||||
|
$"|UWP|ImageFromPath|{path}" +
|
||||||
$"|Unable to get logo for {UserModelId} from {path} and" +
|
$"|Unable to get logo for {UserModelId} from {path} and" +
|
||||||
$" located in {Package.Location}", new FileNotFoundException());
|
$" located in {Package.Location}", new FileNotFoundException());
|
||||||
return new BitmapImage(new Uri(ImageLoader.ErrorIconPath));
|
return new BitmapImage(new Uri(ImageLoader.ErrorIconPath));
|
||||||
@@ -491,5 +496,4 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
return $"{DisplayName}: {Description}";
|
return $"{DisplayName}: {Description}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
|
|
||||||
public string ExecutableName { get; set; }
|
public string ExecutableName { get; set; }
|
||||||
|
|
||||||
public string Description { get; set; } = String.Empty;
|
public string Description { get; set; } = string.Empty;
|
||||||
|
|
||||||
public bool Valid { get; set; }
|
public bool Valid { get; set; }
|
||||||
|
|
||||||
@@ -49,14 +49,14 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
|
|
||||||
public bool hasArguments { get; set; } = false;
|
public bool hasArguments { get; set; } = false;
|
||||||
|
|
||||||
public string Arguments { get; set; } = String.Empty;
|
public string Arguments { get; set; } = string.Empty;
|
||||||
|
|
||||||
public string Location => ParentDirectory;
|
public string Location => ParentDirectory;
|
||||||
|
|
||||||
public uint AppType { get; set; }
|
public uint AppType { get; set; }
|
||||||
|
|
||||||
// Wrappers for File Operations
|
// Wrappers for File Operations
|
||||||
public static IFileVersionInfoWrapper FileVersionInfoWrapper { get; set;} = new FileVersionInfoWrapper();
|
public static IFileVersionInfoWrapper FileVersionInfoWrapper { get; set; } = new FileVersionInfoWrapper();
|
||||||
|
|
||||||
public static IFileWrapper FileWrapper { get; set; } = new FileWrapper();
|
public static IFileWrapper FileWrapper { get; set; } = new FileWrapper();
|
||||||
|
|
||||||
@@ -126,6 +126,7 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
nameContainsQuery = true;
|
nameContainsQuery = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return pathContainsQuery && !nameContainsQuery;
|
return pathContainsQuery && !nameContainsQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,7 +151,7 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return String.Empty;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,7 +168,7 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
|
|
||||||
public Result Result(string query, IPublicAPI api)
|
public Result Result(string query, IPublicAPI api)
|
||||||
{
|
{
|
||||||
if(api == null)
|
if (api == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(api));
|
throw new ArgumentNullException(nameof(api));
|
||||||
}
|
}
|
||||||
@@ -219,7 +220,7 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
// To set the title for the result to always be the name of the application
|
// To set the title for the result to always be the name of the application
|
||||||
result.Title = Name;
|
result.Title = Name;
|
||||||
result.TitleHighlightData = StringMatcher.FuzzySearch(query, Name).MatchData;
|
result.TitleHighlightData = StringMatcher.FuzzySearch(query, Name).MatchData;
|
||||||
|
|
||||||
@@ -336,7 +337,8 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
}
|
}
|
||||||
catch (Exception e) when (e is SecurityException || e is UnauthorizedAccessException)
|
catch (Exception e) when (e is SecurityException || e is UnauthorizedAccessException)
|
||||||
{
|
{
|
||||||
ProgramLogger.LogException($"|Win32|Win32Program|{path}" +
|
ProgramLogger.LogException(
|
||||||
|
$"|Win32|Win32Program|{path}" +
|
||||||
$"|Permission denied when trying to load the program from {path}", e);
|
$"|Permission denied when trying to load the program from {path}", e);
|
||||||
|
|
||||||
return new Win32Program() { Valid = false, Enabled = false };
|
return new Win32Program() { Valid = false, Enabled = false };
|
||||||
@@ -401,7 +403,8 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
}
|
}
|
||||||
catch (Exception e) when (e is SecurityException || e is UnauthorizedAccessException)
|
catch (Exception e) when (e is SecurityException || e is UnauthorizedAccessException)
|
||||||
{
|
{
|
||||||
ProgramLogger.LogException($"|Win32|InternetShortcutProgram|{path}" +
|
ProgramLogger.LogException(
|
||||||
|
$"|Win32|InternetShortcutProgram|{path}" +
|
||||||
$"|Permission denied when trying to load the program from {path}", e);
|
$"|Permission denied when trying to load the program from {path}", e);
|
||||||
|
|
||||||
return new Win32Program() { Valid = false, Enabled = false };
|
return new Win32Program() { Valid = false, Enabled = false };
|
||||||
@@ -445,13 +448,16 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return program;
|
return program;
|
||||||
}
|
}
|
||||||
//Only do a catch all in production. This is so make developer aware of any unhandled exception and add the exception handling in.
|
|
||||||
//Error caused likely due to trying to get the description of the program
|
// Only do a catch all in production. This is so make developer aware of any unhandled exception and add the exception handling in.
|
||||||
|
// Error caused likely due to trying to get the description of the program
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
ProgramLogger.LogException($"|Win32|LnkProgram|{path}" +
|
ProgramLogger.LogException(
|
||||||
|
$"|Win32|LnkProgram|{path}" +
|
||||||
"|An unexpected error occurred in the calling method LnkProgram", e);
|
"|An unexpected error occurred in the calling method LnkProgram", e);
|
||||||
|
|
||||||
program.Valid = false;
|
program.Valid = false;
|
||||||
@@ -475,7 +481,8 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
}
|
}
|
||||||
catch (Exception e) when (e is SecurityException || e is UnauthorizedAccessException)
|
catch (Exception e) when (e is SecurityException || e is UnauthorizedAccessException)
|
||||||
{
|
{
|
||||||
ProgramLogger.LogException($"|Win32|ExeProgram|{path}" +
|
ProgramLogger.LogException(
|
||||||
|
$"|Win32|ExeProgram|{path}" +
|
||||||
$"|Permission denied when trying to load the program from {path}", e);
|
$"|Permission denied when trying to load the program from {path}", e);
|
||||||
|
|
||||||
return new Win32Program() { Valid = false, Enabled = false };
|
return new Win32Program() { Valid = false, Enabled = false };
|
||||||
@@ -524,7 +531,6 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IEnumerable<string> ProgramPaths(string directory, IList<string> suffixes, bool recursiveSearch = true)
|
private static IEnumerable<string> ProgramPaths(string directory, IList<string> suffixes, bool recursiveSearch = true)
|
||||||
@@ -551,14 +557,16 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
}
|
}
|
||||||
catch (DirectoryNotFoundException e)
|
catch (DirectoryNotFoundException e)
|
||||||
{
|
{
|
||||||
ProgramLogger.LogException($"|Win32|ProgramPaths|{currentDirectory}" +
|
ProgramLogger.LogException(
|
||||||
|
$"|Win32|ProgramPaths|{currentDirectory}" +
|
||||||
"|The directory trying to load the program from does not exist", e);
|
"|The directory trying to load the program from does not exist", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e) when (e is SecurityException || e is UnauthorizedAccessException)
|
catch (Exception e) when (e is SecurityException || e is UnauthorizedAccessException)
|
||||||
{
|
{
|
||||||
ProgramLogger.LogException($"|Win32|ProgramPaths|{currentDirectory}" +
|
ProgramLogger.LogException(
|
||||||
|
$"|Win32|ProgramPaths|{currentDirectory}" +
|
||||||
$"|Permission denied when trying to load programs from {currentDirectory}", e);
|
$"|Permission denied when trying to load programs from {currentDirectory}", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -577,7 +585,8 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
}
|
}
|
||||||
catch (Exception e) when (e is SecurityException || e is UnauthorizedAccessException)
|
catch (Exception e) when (e is SecurityException || e is UnauthorizedAccessException)
|
||||||
{
|
{
|
||||||
ProgramLogger.LogException($"|Win32|ProgramPaths|{currentDirectory}" +
|
ProgramLogger.LogException(
|
||||||
|
$"|Win32|ProgramPaths|{currentDirectory}" +
|
||||||
$"|Permission denied when trying to load programs from {currentDirectory}", e);
|
$"|Permission denied when trying to load programs from {currentDirectory}", e);
|
||||||
}
|
}
|
||||||
} while (folderQueue.Any());
|
} while (folderQueue.Any());
|
||||||
@@ -627,7 +636,7 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
// To get all the locations stored in the PATH env variable
|
// To get all the locations stored in the PATH env variable
|
||||||
var pathEnvVariable = Environment.GetEnvironmentVariable("PATH");
|
var pathEnvVariable = Environment.GetEnvironmentVariable("PATH");
|
||||||
string[] searchPaths = pathEnvVariable.Split(Path.PathSeparator);
|
string[] searchPaths = pathEnvVariable.Split(Path.PathSeparator);
|
||||||
IEnumerable<String> toFilterAllPaths = new List<String>();
|
IEnumerable<string> toFilterAllPaths = new List<string>();
|
||||||
bool isRecursiveSearch = true;
|
bool isRecursiveSearch = true;
|
||||||
|
|
||||||
foreach (string path in searchPaths)
|
foreach (string path in searchPaths)
|
||||||
@@ -714,6 +723,7 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
programs.AddRange(GetProgramsFromRegistry(root));
|
programs.AddRange(GetProgramsFromRegistry(root));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
using (var root = Registry.CurrentUser.OpenSubKey(appPaths))
|
using (var root = Registry.CurrentUser.OpenSubKey(appPaths))
|
||||||
{
|
{
|
||||||
if (root != null)
|
if (root != null)
|
||||||
@@ -761,7 +771,8 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
}
|
}
|
||||||
catch (Exception e) when (e is SecurityException || e is UnauthorizedAccessException)
|
catch (Exception e) when (e is SecurityException || e is UnauthorizedAccessException)
|
||||||
{
|
{
|
||||||
ProgramLogger.LogException($"|Win32|GetProgramPathFromRegistrySubKeys|{path}" +
|
ProgramLogger.LogException(
|
||||||
|
$"|Win32|GetProgramPathFromRegistrySubKeys|{path}" +
|
||||||
$"|Permission denied when trying to load the program from {path}", e);
|
$"|Permission denied when trying to load the program from {path}", e);
|
||||||
|
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
@@ -810,6 +821,7 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
&& app1.ExecutableName.Equals(app2.ExecutableName, StringComparison.OrdinalIgnoreCase)
|
&& app1.ExecutableName.Equals(app2.ExecutableName, StringComparison.OrdinalIgnoreCase)
|
||||||
&& app1.FullPath.Equals(app2.FullPath, StringComparison.OrdinalIgnoreCase);
|
&& app1.FullPath.Equals(app2.FullPath, StringComparison.OrdinalIgnoreCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -830,7 +842,7 @@ namespace Microsoft.Plugin.Program.Programs
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Deduplication code
|
// Deduplication code
|
||||||
public static Win32Program[] DeduplicatePrograms(ParallelQuery<Win32Program> programs)
|
public static Win32Program[] DeduplicatePrograms(ParallelQuery<Win32Program> programs)
|
||||||
{
|
{
|
||||||
var uniqueExePrograms = programs.Where(x => !(string.IsNullOrEmpty(x.LnkResolvedPath) && (Extension(x.FullPath) == ExeExtension) && !(x.AppType == (uint)ApplicationTypes.RUN_COMMAND)));
|
var uniqueExePrograms = programs.Where(x => !(string.IsNullOrEmpty(x.LnkResolvedPath) && (Extension(x.FullPath) == ExeExtension) && !(x.AppType == (uint)ApplicationTypes.RUN_COMMAND)));
|
||||||
var uniquePrograms = uniqueExePrograms.Distinct(new removeDuplicatesComparer());
|
var uniquePrograms = uniqueExePrograms.Distinct(new removeDuplicatesComparer());
|
||||||
|
|||||||
@@ -48,10 +48,10 @@ namespace Microsoft.Plugin.Program.Storage
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//InitializeAppInfo will throw if there is no AppxManifest.xml for the package.
|
|
||||||
//Note there are sometimes multiple packages per product and this doesn't necessarily mean that we haven't found the app.
|
|
||||||
//eg. "Could not find file 'C:\\Program Files\\WindowsApps\\Microsoft.WindowsTerminalPreview_2020.616.45.0_neutral_~_8wekyb3d8bbwe\\AppxManifest.xml'."
|
|
||||||
|
|
||||||
|
// InitializeAppInfo will throw if there is no AppxManifest.xml for the package.
|
||||||
|
// Note there are sometimes multiple packages per product and this doesn't necessarily mean that we haven't found the app.
|
||||||
|
// eg. "Could not find file 'C:\\Program Files\\WindowsApps\\Microsoft.WindowsTerminalPreview_2020.616.45.0_neutral_~_8wekyb3d8bbwe\\AppxManifest.xml'."
|
||||||
catch (System.IO.FileNotFoundException e)
|
catch (System.IO.FileNotFoundException e)
|
||||||
{
|
{
|
||||||
ProgramLogger.LogException($"|UWP|OnPackageInstalling|{args.Package.InstalledLocation}|{e.Message}", e);
|
ProgramLogger.LogException($"|UWP|OnPackageInstalling|{args.Package.InstalledLocation}|{e.Message}", e);
|
||||||
@@ -63,7 +63,7 @@ namespace Microsoft.Plugin.Program.Storage
|
|||||||
{
|
{
|
||||||
if (args.Progress == 0)
|
if (args.Progress == 0)
|
||||||
{
|
{
|
||||||
//find apps associated with this package.
|
// find apps associated with this package.
|
||||||
var packageWrapper = PackageWrapper.GetWrapperFromPackage(args.Package);
|
var packageWrapper = PackageWrapper.GetWrapperFromPackage(args.Package);
|
||||||
var uwp = new UWP(packageWrapper);
|
var uwp = new UWP(packageWrapper);
|
||||||
var apps = Items.Where(a => a.Package.Equals(uwp)).ToArray();
|
var apps = Items.Where(a => a.Package.Equals(uwp)).ToArray();
|
||||||
|
|||||||
@@ -60,10 +60,10 @@ namespace Microsoft.Plugin.Program.Storage
|
|||||||
{
|
{
|
||||||
_fileSystemWatchers[index].Dispose();
|
_fileSystemWatchers[index].Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
_disposed = true;
|
_disposed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -151,6 +151,7 @@ namespace Microsoft.Plugin.Program.Storage
|
|||||||
return app;
|
return app;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,6 +166,7 @@ namespace Microsoft.Plugin.Program.Storage
|
|||||||
return app;
|
return app;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,6 +212,5 @@ namespace Microsoft.Plugin.Program.Storage
|
|||||||
var items = _storage.TryLoad(Array.Empty<Win32Program>());
|
var items = _storage.TryLoad(Array.Empty<Win32Program>());
|
||||||
Set(items);
|
Set(items);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ namespace Microsoft.Plugin.Program.Views.Commands
|
|||||||
if (selectedItems.Where(t1 => t1.Enabled).Any())
|
if (selectedItems.Where(t1 => t1.Enabled).Any())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// ProgramSources holds list of user added directories,
|
// ProgramSources holds list of user added directories,
|
||||||
// so when we enable/disable we need to reindex to show/not show the programs
|
// so when we enable/disable we need to reindex to show/not show the programs
|
||||||
// that are found in those directories.
|
// that are found in those directories.
|
||||||
if (selectedItems.Where(t1 => Main._settings.ProgramSources.Any(x => t1.UniqueIdentifier == x.UniqueIdentifier)).Any())
|
if (selectedItems.Where(t1 => Main._settings.ProgramSources.Any(x => t1.UniqueIdentifier == x.UniqueIdentifier)).Any())
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ namespace Microsoft.Plugin.Program.Views
|
|||||||
private ListSortDirection _lastDirection;
|
private ListSortDirection _lastDirection;
|
||||||
|
|
||||||
// We do not save all program sources to settings, so using
|
// We do not save all program sources to settings, so using
|
||||||
// this as temporary holder for displaying all loaded programs sources.
|
// this as temporary holder for displaying all loaded programs sources.
|
||||||
internal static List<ProgramSource> ProgramSettingDisplayList { get; set; }
|
internal static List<ProgramSource> ProgramSettingDisplayList { get; set; }
|
||||||
|
|
||||||
public ProgramSetting(PluginInitContext context, ProgramPluginSettings settings)
|
public ProgramSetting(PluginInitContext context, ProgramPluginSettings settings)
|
||||||
|
|||||||
Reference in New Issue
Block a user