mirror of
https://github.com/velopack/velopack.git
synced 2025-10-25 15:19:22 +00:00
helper method to set app id
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user