mirror of
https://github.com/terrymacdonald/DisplayMagician.git
synced 2024-08-30 18:32:20 +00:00
Register DisplayMagician AUMID with Win10
This registers the Application User Model ID with Win 10 so that it recognises the application and can interact with it. This allows Toasts, Taskbar pinning, right-click menus and other functions to work.
This commit is contained in:
parent
40ab916050
commit
7a730b7a36
@ -306,6 +306,15 @@
|
|||||||
<Isolated>False</Isolated>
|
<Isolated>False</Isolated>
|
||||||
<EmbedInteropTypes>True</EmbedInteropTypes>
|
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||||
</COMReference>
|
</COMReference>
|
||||||
|
<COMReference Include="Shell32">
|
||||||
|
<Guid>{50A7E9B0-70EF-11D1-B75A-00A0C90564FE}</Guid>
|
||||||
|
<VersionMajor>1</VersionMajor>
|
||||||
|
<VersionMinor>0</VersionMinor>
|
||||||
|
<Lcid>0</Lcid>
|
||||||
|
<WrapperTool>tlbimp</WrapperTool>
|
||||||
|
<Isolated>False</Isolated>
|
||||||
|
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||||
|
</COMReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
@ -13,6 +13,7 @@ using DisplayMagician.Shared;
|
|||||||
using DisplayMagician.UIForms;
|
using DisplayMagician.UIForms;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace DisplayMagician {
|
namespace DisplayMagician {
|
||||||
|
|
||||||
@ -25,7 +26,7 @@ namespace DisplayMagician {
|
|||||||
|
|
||||||
internal static class Program
|
internal static class Program
|
||||||
{
|
{
|
||||||
|
internal static string AUMID = "LittleBitBig.DisplayMagician";
|
||||||
internal static string AppDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "DisplayMagician");
|
internal static string AppDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "DisplayMagician");
|
||||||
public static string AppIconPath = Path.Combine(Program.AppDataPath, $"Icons");
|
public static string AppIconPath = Path.Combine(Program.AppDataPath, $"Icons");
|
||||||
public static string AppProfilePath = Path.Combine(Program.AppDataPath, $"Profiles");
|
public static string AppProfilePath = Path.Combine(Program.AppDataPath, $"Profiles");
|
||||||
@ -48,6 +49,11 @@ namespace DisplayMagician {
|
|||||||
private static int Main(string[] args)
|
private static int Main(string[] args)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// This sets the Application User Model ID to "LittleBitBig.DisplayMagician" so that
|
||||||
|
// Windows 10 recognises the application, and allows features such as Toasts,
|
||||||
|
// taskbar pinning and similar.
|
||||||
|
SetCurrentProcessExplicitAppUserModelID(AUMID);
|
||||||
|
|
||||||
// Prepare NLog for logging
|
// Prepare NLog for logging
|
||||||
var config = new NLog.Config.LoggingConfiguration();
|
var config = new NLog.Config.LoggingConfiguration();
|
||||||
|
|
||||||
@ -602,6 +608,14 @@ namespace DisplayMagician {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add the ability to set an Application AUMID so that Windows 10+ recognises the
|
||||||
|
// application and things like Toasts, Tasbar pinning and similar functionality
|
||||||
|
// works as intended. This DLL import avoids the need to package the app as an MSIX
|
||||||
|
// or moving to a WiX based installer at this stage, or the need to add this to the
|
||||||
|
// Windows Store.
|
||||||
|
[DllImport("shell32.dll", SetLastError = true)]
|
||||||
|
static extern void SetCurrentProcessExplicitAppUserModelID([MarshalAs(UnmanagedType.LPWStr)] string AppID);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user