helper method to set app id

This commit is contained in:
Caelan Sayler
2021-11-04 23:41:50 +00:00
parent d6a46b8fe3
commit c1df663498
2 changed files with 20 additions and 2 deletions

View File

@@ -8,7 +8,7 @@ using System.Threading.Tasks;
namespace Squirrel
{
public static class NativeMethods
internal static class NativeMethods
{
public static int GetParentProcessId()
{
@@ -31,6 +31,9 @@ namespace Squirrel
return (int) pbi.InheritedFromUniqueProcessId;
}
[DllImport("shell32.dll", SetLastError = true)]
public static extern void SetCurrentProcessExplicitAppUserModelID([MarshalAs(UnmanagedType.LPWStr)] string AppID);
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern IntPtr LoadLibraryEx(string lpModuleName, IntPtr hFile, uint dwFlags);

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.Contracts;
@@ -146,6 +146,21 @@ namespace Squirrel
return appDirName.ToSemanticVersion();
}
public void SetProcessAppUserModelId()
{
var releases = Utility.LoadLocalReleases(Utility.LocalReleaseFileForAppDir(rootAppDirectory));
var thisRelease = Utility.FindCurrentVersion(releases);
var zf = new ZipPackage(Path.Combine(
Utility.PackageDirectoryForAppDir(rootAppDirectory),
thisRelease.Filename));
var exeName = Path.GetFileName(AssemblyRuntimeInfo.EntryExePath);
var appUserModelId = String.Format("com.squirrel.{0}.{1}", zf.Id.Replace(" ", ""), exeName.Replace(".exe", "").Replace(" ", ""));
NativeMethods.SetCurrentProcessExplicitAppUserModelID(appUserModelId);
}
public void KillAllExecutablesBelongingToPackage()
{
var installHelpers = new InstallHelperImpl(applicationName, rootAppDirectory);