|
|
@ -1,11 +1,14 @@
|
|
|
|
using System;
|
|
|
|
#nullable enable
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
using System.Text;
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
using Vanara.Extensions;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Vanara.PInvoke
|
|
|
|
namespace Vanara.PInvoke;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static partial class Kernel32
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public static partial class Kernel32
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// Defines options that can be applied when adding a run-time reference to a framework package by using the AddPackageDependency function.
|
|
|
|
/// Defines options that can be applied when adding a run-time reference to a framework package by using the AddPackageDependency function.
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
@ -623,6 +626,49 @@ namespace Vanara.PInvoke
|
|
|
|
[PInvokeData("appmodel.h", MSDNShortId = "D52E98BD-726F-4AC0-A034-02896B1D1687")]
|
|
|
|
[PInvokeData("appmodel.h", MSDNShortId = "D52E98BD-726F-4AC0-A034-02896B1D1687")]
|
|
|
|
public static extern Win32Error FindPackagesByPackageFamily(string packageFamilyName, PACKAGE_FLAGS packageFilters, ref uint count, IntPtr packageFullNames, ref uint bufferLength, IntPtr buffer, IntPtr packageProperties);
|
|
|
|
public static extern Win32Error FindPackagesByPackageFamily(string packageFamilyName, PACKAGE_FLAGS packageFilters, ref uint count, IntPtr packageFullNames, ref uint bufferLength, IntPtr buffer, IntPtr packageProperties);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Finds the packages with the specified family name for the current user.</summary>
|
|
|
|
|
|
|
|
/// <param name="packageFamilyName"><para>Type: <c>PCWSTR</c></para>
|
|
|
|
|
|
|
|
/// <para>The package family name.</para></param>
|
|
|
|
|
|
|
|
/// <param name="packageFilters"><para>Type: <c>UINT32</c></para>
|
|
|
|
|
|
|
|
/// <para>
|
|
|
|
|
|
|
|
/// The package constants that specify how package information is retrieved. All package constants except
|
|
|
|
|
|
|
|
/// <c>PACKAGE_FILTER_ALL_LOADED</c> are supported.
|
|
|
|
|
|
|
|
/// </para></param>
|
|
|
|
|
|
|
|
/// <param name="packageFullNames"><para>Type: <c>PWSTR*</c></para>
|
|
|
|
|
|
|
|
/// <para>Receives the strings of package full names that were found.</para></param>
|
|
|
|
|
|
|
|
/// <param name="packageProperties"><para>Type: <c>UINT32*</c></para>
|
|
|
|
|
|
|
|
/// <para>Receives the package properties for all of the packages that were found.</para></param>
|
|
|
|
|
|
|
|
/// <returns>
|
|
|
|
|
|
|
|
/// <para>Type: <c>LONG</c></para>
|
|
|
|
|
|
|
|
/// <para>
|
|
|
|
|
|
|
|
/// If the function succeeds it returns <c>ERROR_SUCCESS</c>. Otherwise, the function returns an error code.
|
|
|
|
|
|
|
|
/// </para>
|
|
|
|
|
|
|
|
/// </returns>
|
|
|
|
|
|
|
|
// https://docs.microsoft.com/en-us/windows/desktop/api/appmodel/nf-appmodel-findpackagesbypackagefamily LONG
|
|
|
|
|
|
|
|
// FindPackagesByPackageFamily( PCWSTR packageFamilyName, UINT32 packageFilters, UINT32 *count, PWSTR *packageFullNames, UINT32
|
|
|
|
|
|
|
|
// *bufferLength, WCHAR *buffer, UINT32 *packageProperties );
|
|
|
|
|
|
|
|
[PInvokeData("appmodel.h", MSDNShortId = "D52E98BD-726F-4AC0-A034-02896B1D1687")]
|
|
|
|
|
|
|
|
public static Win32Error FindPackagesByPackageFamily(string packageFamilyName, PACKAGE_FLAGS packageFilters, out string?[] packageFullNames, out uint[] packageProperties)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
uint count = 0, bufferLength = 0;
|
|
|
|
|
|
|
|
packageFullNames = new string[0];
|
|
|
|
|
|
|
|
packageProperties = new uint[0];
|
|
|
|
|
|
|
|
Win32Error err = FindPackagesByPackageFamily(packageFamilyName, packageFilters, ref count, default, ref bufferLength, default, default);
|
|
|
|
|
|
|
|
if (count == 0 || err != Win32Error.ERROR_INSUFFICIENT_BUFFER)
|
|
|
|
|
|
|
|
return err;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using InteropServices.SafeCoTaskMemHandle mem = new(count * IntPtr.Size + bufferLength * StringHelper.GetCharSize(CharSet.Unicode) + count * sizeof(uint));
|
|
|
|
|
|
|
|
IntPtr buffer = mem.DangerousGetHandle().Offset(count * IntPtr.Size);
|
|
|
|
|
|
|
|
IntPtr props = mem.DangerousGetHandle().Offset(count * IntPtr.Size + bufferLength * StringHelper.GetCharSize(CharSet.Unicode));
|
|
|
|
|
|
|
|
err = FindPackagesByPackageFamily(packageFamilyName, packageFilters, ref count, mem, ref bufferLength, buffer, props);
|
|
|
|
|
|
|
|
if (err.Succeeded)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
packageFullNames = mem.ToStringEnum((int)count, CharSet.Unicode).ToArray();
|
|
|
|
|
|
|
|
packageProperties = props.ToArray<uint>((int)count)!;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return err;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// <para>Constructs an application user model ID from the package family name and the package relative application ID (PRAID).</para>
|
|
|
|
/// <para>Constructs an application user model ID from the package family name and the package relative application ID (PRAID).</para>
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
@ -679,7 +725,7 @@ namespace Vanara.PInvoke
|
|
|
|
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
|
|
|
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
|
|
|
[PInvokeData("appmodel.h", MSDNShortId = "F48D19C2-6373-41FC-A99D-E3CCB68D6C6C")]
|
|
|
|
[PInvokeData("appmodel.h", MSDNShortId = "F48D19C2-6373-41FC-A99D-E3CCB68D6C6C")]
|
|
|
|
public static extern Win32Error FormatApplicationUserModelId(string packageFamilyName, string packageRelativeApplicationId,
|
|
|
|
public static extern Win32Error FormatApplicationUserModelId(string packageFamilyName, string packageRelativeApplicationId,
|
|
|
|
ref uint applicationUserModelIdLength, [Optional] StringBuilder applicationUserModelId);
|
|
|
|
ref uint applicationUserModelIdLength, [Optional] StringBuilder? applicationUserModelId);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// <para>Gets the application user model ID for the specified process.</para>
|
|
|
|
/// <para>Gets the application user model ID for the specified process.</para>
|
|
|
@ -728,7 +774,7 @@ namespace Vanara.PInvoke
|
|
|
|
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
|
|
|
|
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true)]
|
|
|
|
[PInvokeData("appmodel.h", MSDNShortId = "FE4E0818-F548-494B-B3BD-FB51DC748451")]
|
|
|
|
[PInvokeData("appmodel.h", MSDNShortId = "FE4E0818-F548-494B-B3BD-FB51DC748451")]
|
|
|
|
public static extern Win32Error GetApplicationUserModelId(HPROCESS hProcess, ref uint applicationUserModelIdLength,
|
|
|
|
public static extern Win32Error GetApplicationUserModelId(HPROCESS hProcess, ref uint applicationUserModelIdLength,
|
|
|
|
[Optional, MarshalAs(UnmanagedType.LPWStr)] StringBuilder applicationUserModelId);
|
|
|
|
[Optional, MarshalAs(UnmanagedType.LPWStr)] StringBuilder? applicationUserModelId);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// <para>Gets the application user model ID for the specified token.</para>
|
|
|
|
/// <para>Gets the application user model ID for the specified token.</para>
|
|
|
@ -777,7 +823,7 @@ namespace Vanara.PInvoke
|
|
|
|
[DllImport(Lib.KernelBase, SetLastError = true, ExactSpelling = true)]
|
|
|
|
[DllImport(Lib.KernelBase, SetLastError = true, ExactSpelling = true)]
|
|
|
|
[PInvokeData("appmodel.h", MSDNShortId = "80036518-927E-4CD0-B499-8EA472AB7E5A")]
|
|
|
|
[PInvokeData("appmodel.h", MSDNShortId = "80036518-927E-4CD0-B499-8EA472AB7E5A")]
|
|
|
|
public static extern Win32Error GetApplicationUserModelIdFromToken(HTOKEN token, ref uint applicationUserModelIdLength,
|
|
|
|
public static extern Win32Error GetApplicationUserModelIdFromToken(HTOKEN token, ref uint applicationUserModelIdLength,
|
|
|
|
[Optional, MarshalAs(UnmanagedType.LPWStr)] StringBuilder applicationUserModelId);
|
|
|
|
[Optional, MarshalAs(UnmanagedType.LPWStr)] StringBuilder? applicationUserModelId);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// <para>Gets the application user model ID for the current process.</para>
|
|
|
|
/// <para>Gets the application user model ID for the current process.</para>
|
|
|
@ -819,7 +865,7 @@ namespace Vanara.PInvoke
|
|
|
|
// GetCurrentApplicationUserModelId( UINT32 *applicationUserModelIdLength, PWSTR applicationUserModelId );
|
|
|
|
// GetCurrentApplicationUserModelId( UINT32 *applicationUserModelIdLength, PWSTR applicationUserModelId );
|
|
|
|
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
|
|
|
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
|
|
|
[PInvokeData("appmodel.h", MSDNShortId = "562BB225-0922-4FE7-92C0-573A2CCE3195")]
|
|
|
|
[PInvokeData("appmodel.h", MSDNShortId = "562BB225-0922-4FE7-92C0-573A2CCE3195")]
|
|
|
|
public static extern Win32Error GetCurrentApplicationUserModelId(ref uint applicationUserModelIdLength, [Optional] StringBuilder applicationUserModelId);
|
|
|
|
public static extern Win32Error GetCurrentApplicationUserModelId(ref uint applicationUserModelIdLength, [Optional] StringBuilder? applicationUserModelId);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// <para>Gets the package family name for the calling process.</para>
|
|
|
|
/// <para>Gets the package family name for the calling process.</para>
|
|
|
@ -864,7 +910,7 @@ namespace Vanara.PInvoke
|
|
|
|
// GetCurrentPackageFamilyName( UINT32 *packageFamilyNameLength, PWSTR packageFamilyName );
|
|
|
|
// GetCurrentPackageFamilyName( UINT32 *packageFamilyNameLength, PWSTR packageFamilyName );
|
|
|
|
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
|
|
|
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
|
|
|
[PInvokeData("appmodel.h", MSDNShortId = "39DBFBDD-A1CC-45C3-A5DD-5ED9697F9AFE")]
|
|
|
|
[PInvokeData("appmodel.h", MSDNShortId = "39DBFBDD-A1CC-45C3-A5DD-5ED9697F9AFE")]
|
|
|
|
public static extern Win32Error GetCurrentPackageFamilyName(ref uint packageFamilyNameLength, [Optional] StringBuilder packageFamilyName);
|
|
|
|
public static extern Win32Error GetCurrentPackageFamilyName(ref uint packageFamilyNameLength, [Optional] StringBuilder? packageFamilyName);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// <para>Gets the package full name for the calling process.</para>
|
|
|
|
/// <para>Gets the package full name for the calling process.</para>
|
|
|
@ -909,7 +955,7 @@ namespace Vanara.PInvoke
|
|
|
|
// GetCurrentPackageFullName( UINT32 *packageFullNameLength, PWSTR packageFullName );
|
|
|
|
// GetCurrentPackageFullName( UINT32 *packageFullNameLength, PWSTR packageFullName );
|
|
|
|
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
|
|
|
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
|
|
|
[PInvokeData("appmodel.h", MSDNShortId = "D5B00C53-1FBF-4245-92D1-FA39713A9EE7")]
|
|
|
|
[PInvokeData("appmodel.h", MSDNShortId = "D5B00C53-1FBF-4245-92D1-FA39713A9EE7")]
|
|
|
|
public static extern Win32Error GetCurrentPackageFullName(ref uint packageFullNameLength, [Optional] StringBuilder packageFullName);
|
|
|
|
public static extern Win32Error GetCurrentPackageFullName(ref uint packageFullNameLength, [Optional] StringBuilder? packageFullName);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// <para>Gets the package identifier (ID) for the calling process.</para>
|
|
|
|
/// <para>Gets the package identifier (ID) for the calling process.</para>
|
|
|
@ -1091,7 +1137,7 @@ namespace Vanara.PInvoke
|
|
|
|
// *pathLength, PWSTR path );
|
|
|
|
// *pathLength, PWSTR path );
|
|
|
|
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
|
|
|
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
|
|
|
[PInvokeData("appmodel.h", MSDNShortId = "46CE81DF-A9D5-492E-AB5E-4F043DC326E2")]
|
|
|
|
[PInvokeData("appmodel.h", MSDNShortId = "46CE81DF-A9D5-492E-AB5E-4F043DC326E2")]
|
|
|
|
public static extern Win32Error GetCurrentPackagePath(ref uint pathLength, [Optional] StringBuilder path);
|
|
|
|
public static extern Win32Error GetCurrentPackagePath(ref uint pathLength, [Optional] StringBuilder? path);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the package path for the calling process, with the option to specify the type of folder path to retrieve for the package.
|
|
|
|
/// Gets the package path for the calling process, with the option to specify the type of folder path to retrieve for the package.
|
|
|
@ -1144,7 +1190,7 @@ namespace Vanara.PInvoke
|
|
|
|
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)]
|
|
|
|
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)]
|
|
|
|
[PInvokeData("appmodel.h")]
|
|
|
|
[PInvokeData("appmodel.h")]
|
|
|
|
public static extern Win32Error GetCurrentPackagePath2(PackagePathType packagePathType, ref uint pathLength,
|
|
|
|
public static extern Win32Error GetCurrentPackagePath2(PackagePathType packagePathType, ref uint pathLength,
|
|
|
|
[Optional, MarshalAs(UnmanagedType.LPWStr)] StringBuilder path);
|
|
|
|
[Optional, MarshalAs(UnmanagedType.LPWStr)] StringBuilder? path);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Returns the package dependency for the specified context handle.</summary>
|
|
|
|
/// <summary>Returns the package dependency for the specified context handle.</summary>
|
|
|
|
/// <param name="packageDependencyContext">
|
|
|
|
/// <param name="packageDependencyContext">
|
|
|
@ -1274,7 +1320,7 @@ namespace Vanara.PInvoke
|
|
|
|
// hProcess, UINT32 *packageFamilyNameLength, PWSTR packageFamilyName );
|
|
|
|
// hProcess, UINT32 *packageFamilyNameLength, PWSTR packageFamilyName );
|
|
|
|
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
|
|
|
[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
|
|
|
[PInvokeData("appmodel.h", MSDNShortId = "AC239898-9924-4193-9072-7A7EEC2D03E9")]
|
|
|
|
[PInvokeData("appmodel.h", MSDNShortId = "AC239898-9924-4193-9072-7A7EEC2D03E9")]
|
|
|
|
public static extern Win32Error GetPackageFamilyName(HPROCESS hProcess, ref uint packageFamilyNameLength, [Optional] StringBuilder packageFamilyName);
|
|
|
|
public static extern Win32Error GetPackageFamilyName(HPROCESS hProcess, ref uint packageFamilyNameLength, [Optional] StringBuilder? packageFamilyName);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// <para>Gets the package family name for the specified token.</para>
|
|
|
|
/// <para>Gets the package family name for the specified token.</para>
|
|
|
@ -1323,7 +1369,7 @@ namespace Vanara.PInvoke
|
|
|
|
// GetPackageFamilyNameFromToken( HANDLE token, UINT32 *packageFamilyNameLength, PWSTR packageFamilyName );
|
|
|
|
// GetPackageFamilyNameFromToken( HANDLE token, UINT32 *packageFamilyNameLength, PWSTR packageFamilyName );
|
|
|
|
[DllImport(Lib.KernelBase, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
|
|
|
[DllImport(Lib.KernelBase, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
|
|
|
[PInvokeData("appmodel.h", MSDNShortId = "C4FAF5DE-DF1F-4AFA-813B-5D80C786031B")]
|
|
|
|
[PInvokeData("appmodel.h", MSDNShortId = "C4FAF5DE-DF1F-4AFA-813B-5D80C786031B")]
|
|
|
|
public static extern Win32Error GetPackageFamilyNameFromToken(HTOKEN token, ref uint packageFamilyNameLength, [Optional] StringBuilder packageFamilyName);
|
|
|
|
public static extern Win32Error GetPackageFamilyNameFromToken(HTOKEN token, ref uint packageFamilyNameLength, [Optional] StringBuilder? packageFamilyName);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Gets the package full name for the specified process.</summary>
|
|
|
|
/// <summary>Gets the package full name for the specified process.</summary>
|
|
|
|
/// <param name="hProcess">
|
|
|
|
/// <param name="hProcess">
|
|
|
@ -1377,7 +1423,7 @@ namespace Vanara.PInvoke
|
|
|
|
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)]
|
|
|
|
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)]
|
|
|
|
[PInvokeData("appmodel.h", MSDNShortId = "NF:appmodel.GetPackageFullName")]
|
|
|
|
[PInvokeData("appmodel.h", MSDNShortId = "NF:appmodel.GetPackageFullName")]
|
|
|
|
public static extern Win32Error GetPackageFullName(HPROCESS hProcess, ref uint packageFullNameLength,
|
|
|
|
public static extern Win32Error GetPackageFullName(HPROCESS hProcess, ref uint packageFullNameLength,
|
|
|
|
[Optional, MarshalAs(UnmanagedType.LPWStr)] StringBuilder packageFullName);
|
|
|
|
[Optional, MarshalAs(UnmanagedType.LPWStr)] StringBuilder? packageFullName);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// <para>Gets the package full name for the specified token.</para>
|
|
|
|
/// <para>Gets the package full name for the specified token.</para>
|
|
|
@ -1422,7 +1468,7 @@ namespace Vanara.PInvoke
|
|
|
|
// GetPackageFullNameFromToken( HANDLE token, UINT32 *packageFullNameLength, PWSTR packageFullName );
|
|
|
|
// GetPackageFullNameFromToken( HANDLE token, UINT32 *packageFullNameLength, PWSTR packageFullName );
|
|
|
|
[DllImport(Lib.KernelBase, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
|
|
|
[DllImport(Lib.KernelBase, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
|
|
|
[PInvokeData("appmodel.h", MSDNShortId = "7B0D574E-A2F5-4D08-AEFB-9E040BBC729F")]
|
|
|
|
[PInvokeData("appmodel.h", MSDNShortId = "7B0D574E-A2F5-4D08-AEFB-9E040BBC729F")]
|
|
|
|
public static extern Win32Error GetPackageFullNameFromToken(HTOKEN token, ref uint packageFullNameLength, [Optional] StringBuilder packageFullName);
|
|
|
|
public static extern Win32Error GetPackageFullNameFromToken(HTOKEN token, ref uint packageFullNameLength, [Optional] StringBuilder? packageFullName);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// <para>Gets the package information for the specified package.</para>
|
|
|
|
/// <para>Gets the package information for the specified package.</para>
|
|
|
@ -1571,7 +1617,7 @@ namespace Vanara.PInvoke
|
|
|
|
// *packageId, const UINT32 reserved, UINT32 *pathLength, PWSTR path );
|
|
|
|
// *packageId, const UINT32 reserved, UINT32 *pathLength, PWSTR path );
|
|
|
|
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
|
|
|
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
|
|
|
[PInvokeData("appmodel.h", MSDNShortId = "BDA0DD87-A36D-486B-BF89-EA5CC105C742")]
|
|
|
|
[PInvokeData("appmodel.h", MSDNShortId = "BDA0DD87-A36D-486B-BF89-EA5CC105C742")]
|
|
|
|
public static extern Win32Error GetPackagePath(in PACKAGE_ID packageId, uint reserved, ref uint pathLength, [Optional] StringBuilder path);
|
|
|
|
public static extern Win32Error GetPackagePath(in PACKAGE_ID packageId, uint reserved, ref uint pathLength, [Optional] StringBuilder? path);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// <para>Gets the path of the specified package.</para>
|
|
|
|
/// <para>Gets the path of the specified package.</para>
|
|
|
@ -1615,7 +1661,7 @@ namespace Vanara.PInvoke
|
|
|
|
// PCWSTR packageFullName, UINT32 *pathLength, PWSTR path );
|
|
|
|
// PCWSTR packageFullName, UINT32 *pathLength, PWSTR path );
|
|
|
|
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
|
|
|
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
|
|
|
[PInvokeData("appmodel.h", MSDNShortId = "9C25708C-1464-4C59-9740-E9F105116385")]
|
|
|
|
[PInvokeData("appmodel.h", MSDNShortId = "9C25708C-1464-4C59-9740-E9F105116385")]
|
|
|
|
public static extern Win32Error GetPackagePathByFullName(string packageFullName, ref uint pathLength, [Optional] StringBuilder path);
|
|
|
|
public static extern Win32Error GetPackagePathByFullName(string packageFullName, ref uint pathLength, [Optional] StringBuilder? path);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Gets the path of the specified package, with the option to specify the type of folder path to retrieve for the package.</summary>
|
|
|
|
/// <summary>Gets the path of the specified package, with the option to specify the type of folder path to retrieve for the package.</summary>
|
|
|
|
/// <param name="packageFullName">
|
|
|
|
/// <param name="packageFullName">
|
|
|
@ -1669,11 +1715,32 @@ namespace Vanara.PInvoke
|
|
|
|
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)]
|
|
|
|
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)]
|
|
|
|
[PInvokeData("appmodel.h")]
|
|
|
|
[PInvokeData("appmodel.h")]
|
|
|
|
public static extern Win32Error GetPackagePathByFullName2([MarshalAs(UnmanagedType.LPWStr)] string packageFullName, PackagePathType packagePathType,
|
|
|
|
public static extern Win32Error GetPackagePathByFullName2([MarshalAs(UnmanagedType.LPWStr)] string packageFullName, PackagePathType packagePathType,
|
|
|
|
ref uint pathLength, [Optional, MarshalAs(UnmanagedType.LPWStr)] StringBuilder path);
|
|
|
|
ref uint pathLength, [Optional, MarshalAs(UnmanagedType.LPWStr)] StringBuilder? path);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>Gets the packages with the specified family name for the current user.</summary>
|
|
|
|
/// <para>Gets the packages with the specified family name for the current user.</para>
|
|
|
|
/// <param name="packageFamilyName">The package family name.</param>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="packageFullNames">A pointer to the strings of package full names.</param>
|
|
|
|
|
|
|
|
/// <returns>If the function succeeds it returns <c>ERROR_SUCCESS</c>. Otherwise, the function returns an error code.</returns>
|
|
|
|
|
|
|
|
// https://docs.microsoft.com/en-us/windows/desktop/api/appmodel/nf-appmodel-getpackagesbypackagefamily LONG
|
|
|
|
|
|
|
|
// GetPackagesByPackageFamily( PCWSTR packageFamilyName, UINT32 *count, PWSTR *packageFullNames, UINT32 *bufferLength, WCHAR *buffer );
|
|
|
|
|
|
|
|
[PInvokeData("appmodel.h", MSDNShortId = "C2163203-D654-4491-9090-0CC43F42EC35")]
|
|
|
|
|
|
|
|
public static Win32Error GetPackagesByPackageFamily(string packageFamilyName, out string?[] packageFullNames)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
uint count = 0, bufferLength = 0;
|
|
|
|
|
|
|
|
packageFullNames = new string[0];
|
|
|
|
|
|
|
|
Win32Error err = GetPackagesByPackageFamily(packageFamilyName, ref count, default, ref bufferLength, default);
|
|
|
|
|
|
|
|
if (err != Win32Error.ERROR_INSUFFICIENT_BUFFER)
|
|
|
|
|
|
|
|
return err;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using InteropServices.SafeCoTaskMemHandle mem = new(count * IntPtr.Size + bufferLength * StringHelper.GetCharSize(CharSet.Unicode));
|
|
|
|
|
|
|
|
IntPtr buffer = mem.DangerousGetHandle().Offset(count * IntPtr.Size);
|
|
|
|
|
|
|
|
err = GetPackagesByPackageFamily(packageFamilyName, ref count, mem, ref bufferLength, buffer);
|
|
|
|
|
|
|
|
if (err.Succeeded)
|
|
|
|
|
|
|
|
packageFullNames = mem.ToStringEnum((int)count, CharSet.Unicode).ToArray();
|
|
|
|
|
|
|
|
return err;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Gets the packages with the specified family name for the current user.</summary>
|
|
|
|
/// <param name="packageFamilyName">
|
|
|
|
/// <param name="packageFamilyName">
|
|
|
|
/// <para>Type: <c>PCWSTR</c></para>
|
|
|
|
/// <para>Type: <c>PCWSTR</c></para>
|
|
|
|
/// <para>The package family name.</para>
|
|
|
|
/// <para>The package family name.</para>
|
|
|
@ -1682,8 +1749,8 @@ namespace Vanara.PInvoke
|
|
|
|
/// <para>Type: <c>UINT32*</c></para>
|
|
|
|
/// <para>Type: <c>UINT32*</c></para>
|
|
|
|
/// <para>A pointer to a variable that holds the number of package full names.</para>
|
|
|
|
/// <para>A pointer to a variable that holds the number of package full names.</para>
|
|
|
|
/// <para>
|
|
|
|
/// <para>
|
|
|
|
/// First you pass <c>NULL</c> to packageFullNames to get the number of package full names. You use this number to allocate memory
|
|
|
|
/// First you pass <c>NULL</c> to packageFullNames to get the number of package full names. You use this number to allocate memory space
|
|
|
|
/// space for packageFullNames. Then you pass the address of this number to fill packageFullNames.
|
|
|
|
/// for packageFullNames. Then you pass the address of this number to fill packageFullNames.
|
|
|
|
/// </para>
|
|
|
|
/// </para>
|
|
|
|
/// </param>
|
|
|
|
/// </param>
|
|
|
|
/// <param name="packageFullNames">
|
|
|
|
/// <param name="packageFullNames">
|
|
|
@ -1694,8 +1761,8 @@ namespace Vanara.PInvoke
|
|
|
|
/// <para>Type: <c>UINT32*</c></para>
|
|
|
|
/// <para>Type: <c>UINT32*</c></para>
|
|
|
|
/// <para>A pointer to a variable that holds the number of characters in the string of package full names.</para>
|
|
|
|
/// <para>A pointer to a variable that holds the number of characters in the string of package full names.</para>
|
|
|
|
/// <para>
|
|
|
|
/// <para>
|
|
|
|
/// First you pass <c>NULL</c> to buffer to get the number of characters. You use this number to allocate memory space for buffer.
|
|
|
|
/// First you pass <c>NULL</c> to buffer to get the number of characters. You use this number to allocate memory space for buffer. Then
|
|
|
|
/// Then you pass the address of this number to fill buffer.
|
|
|
|
/// you pass the address of this number to fill buffer.
|
|
|
|
/// </para>
|
|
|
|
/// </para>
|
|
|
|
/// </param>
|
|
|
|
/// </param>
|
|
|
|
/// <param name="buffer">
|
|
|
|
/// <param name="buffer">
|
|
|
@ -1705,8 +1772,8 @@ namespace Vanara.PInvoke
|
|
|
|
/// <returns>
|
|
|
|
/// <returns>
|
|
|
|
/// <para>Type: <c>LONG</c></para>
|
|
|
|
/// <para>Type: <c>LONG</c></para>
|
|
|
|
/// <para>
|
|
|
|
/// <para>
|
|
|
|
/// If the function succeeds it returns <c>ERROR_SUCCESS</c>. Otherwise, the function returns an error code. The possible error
|
|
|
|
/// If the function succeeds it returns <c>ERROR_SUCCESS</c>. Otherwise, the function returns an error code. The possible error codes
|
|
|
|
/// codes include the following.
|
|
|
|
/// include the following.
|
|
|
|
/// </para>
|
|
|
|
/// </para>
|
|
|
|
/// <list type="table">
|
|
|
|
/// <list type="table">
|
|
|
|
/// <listheader>
|
|
|
|
/// <listheader>
|
|
|
@ -1723,7 +1790,8 @@ namespace Vanara.PInvoke
|
|
|
|
// GetPackagesByPackageFamily( PCWSTR packageFamilyName, UINT32 *count, PWSTR *packageFullNames, UINT32 *bufferLength, WCHAR *buffer );
|
|
|
|
// GetPackagesByPackageFamily( PCWSTR packageFamilyName, UINT32 *count, PWSTR *packageFullNames, UINT32 *bufferLength, WCHAR *buffer );
|
|
|
|
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
|
|
|
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
|
|
|
[PInvokeData("appmodel.h", MSDNShortId = "C2163203-D654-4491-9090-0CC43F42EC35")]
|
|
|
|
[PInvokeData("appmodel.h", MSDNShortId = "C2163203-D654-4491-9090-0CC43F42EC35")]
|
|
|
|
public static extern Win32Error GetPackagesByPackageFamily(string packageFamilyName, ref uint count, [Out, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr, SizeParamIndex = 1)] string[] packageFullNames, ref uint bufferLength, IntPtr buffer);
|
|
|
|
public static extern Win32Error GetPackagesByPackageFamily(string packageFamilyName, ref uint count,
|
|
|
|
|
|
|
|
[Out] IntPtr packageFullNames, ref uint bufferLength, [Out] IntPtr buffer);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// <para>Gets the origin of the specified package.</para>
|
|
|
|
/// <para>Gets the origin of the specified package.</para>
|
|
|
@ -1810,7 +1878,7 @@ namespace Vanara.PInvoke
|
|
|
|
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)]
|
|
|
|
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)]
|
|
|
|
[PInvokeData("appmodel.h", MSDNShortId = "F0A37D77-6262-44B1-BEC5-083E41BDE139")]
|
|
|
|
[PInvokeData("appmodel.h", MSDNShortId = "F0A37D77-6262-44B1-BEC5-083E41BDE139")]
|
|
|
|
public static extern Win32Error GetStagedPackagePathByFullName([MarshalAs(UnmanagedType.LPWStr)] string packageFullName, ref uint pathLength,
|
|
|
|
public static extern Win32Error GetStagedPackagePathByFullName([MarshalAs(UnmanagedType.LPWStr)] string packageFullName, ref uint pathLength,
|
|
|
|
[Optional, MarshalAs(UnmanagedType.LPWStr)] StringBuilder path);
|
|
|
|
[Optional, MarshalAs(UnmanagedType.LPWStr)] StringBuilder? path);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the path of the specified staged package, with the option to specify the type of folder path to retrieve for the package.
|
|
|
|
/// Gets the path of the specified staged package, with the option to specify the type of folder path to retrieve for the package.
|
|
|
@ -1866,7 +1934,7 @@ namespace Vanara.PInvoke
|
|
|
|
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)]
|
|
|
|
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)]
|
|
|
|
[PInvokeData("appmodel.h")]
|
|
|
|
[PInvokeData("appmodel.h")]
|
|
|
|
public static extern Win32Error GetStagedPackagePathByFullName2([MarshalAs(UnmanagedType.LPWStr)] string packageFullName, PackagePathType packagePathType,
|
|
|
|
public static extern Win32Error GetStagedPackagePathByFullName2([MarshalAs(UnmanagedType.LPWStr)] string packageFullName, PackagePathType packagePathType,
|
|
|
|
ref uint pathLength, [Optional, MarshalAs(UnmanagedType.LPWStr)] StringBuilder path);
|
|
|
|
ref uint pathLength, [Optional, MarshalAs(UnmanagedType.LPWStr)] StringBuilder? path);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// <para>Opens the package information of the specified package.</para>
|
|
|
|
/// <para>Opens the package information of the specified package.</para>
|
|
|
@ -1950,7 +2018,7 @@ namespace Vanara.PInvoke
|
|
|
|
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
|
|
|
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
|
|
|
[PInvokeData("appmodel.h", MSDNShortId = "98E95CE5-E970-4A19-BAD3-994DAEC4BEA0")]
|
|
|
|
[PInvokeData("appmodel.h", MSDNShortId = "98E95CE5-E970-4A19-BAD3-994DAEC4BEA0")]
|
|
|
|
public static extern Win32Error PackageFamilyNameFromFullName(string packageFullName, ref uint packageFamilyNameLength,
|
|
|
|
public static extern Win32Error PackageFamilyNameFromFullName(string packageFullName, ref uint packageFamilyNameLength,
|
|
|
|
[Optional] StringBuilder packageFamilyName);
|
|
|
|
[Optional] StringBuilder? packageFamilyName);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// <para>Gets the package family name for the specified package identifier.</para>
|
|
|
|
/// <para>Gets the package family name for the specified package identifier.</para>
|
|
|
@ -1996,7 +2064,7 @@ namespace Vanara.PInvoke
|
|
|
|
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)]
|
|
|
|
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)]
|
|
|
|
[PInvokeData("appmodel.h", MSDNShortId = "198DAB6B-21D2-4ACB-87DF-B3F4EFBEE323")]
|
|
|
|
[PInvokeData("appmodel.h", MSDNShortId = "198DAB6B-21D2-4ACB-87DF-B3F4EFBEE323")]
|
|
|
|
public static extern Win32Error PackageFamilyNameFromId(in PACKAGE_ID packageId, ref uint packageFamilyNameLength,
|
|
|
|
public static extern Win32Error PackageFamilyNameFromId(in PACKAGE_ID packageId, ref uint packageFamilyNameLength,
|
|
|
|
[Optional, MarshalAs(UnmanagedType.LPWStr)] StringBuilder packageFamilyName);
|
|
|
|
[Optional, MarshalAs(UnmanagedType.LPWStr)] StringBuilder? packageFamilyName);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// <para>Gets the package full name for the specified package identifier (ID).</para>
|
|
|
|
/// <para>Gets the package full name for the specified package identifier (ID).</para>
|
|
|
@ -2042,7 +2110,7 @@ namespace Vanara.PInvoke
|
|
|
|
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)]
|
|
|
|
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true)]
|
|
|
|
[PInvokeData("appmodel.h", MSDNShortId = "0024AF55-295E-49B1-90C2-9144D336529B")]
|
|
|
|
[PInvokeData("appmodel.h", MSDNShortId = "0024AF55-295E-49B1-90C2-9144D336529B")]
|
|
|
|
public static extern Win32Error PackageFullNameFromId(in PACKAGE_ID packageId, ref uint packageFullNameLength,
|
|
|
|
public static extern Win32Error PackageFullNameFromId(in PACKAGE_ID packageId, ref uint packageFullNameLength,
|
|
|
|
[Optional, MarshalAs(UnmanagedType.LPWStr)] StringBuilder packageFullName);
|
|
|
|
[Optional, MarshalAs(UnmanagedType.LPWStr)] StringBuilder? packageFullName);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// <para>Gets the package identifier (ID) for the specified package full name.</para>
|
|
|
|
/// <para>Gets the package identifier (ID) for the specified package full name.</para>
|
|
|
@ -2194,7 +2262,7 @@ namespace Vanara.PInvoke
|
|
|
|
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
|
|
|
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
|
|
|
[PInvokeData("appmodel.h", MSDNShortId = "4AA5BD75-F865-40D6-9C10-E54C197D47C4")]
|
|
|
|
[PInvokeData("appmodel.h", MSDNShortId = "4AA5BD75-F865-40D6-9C10-E54C197D47C4")]
|
|
|
|
public static extern Win32Error PackageNameAndPublisherIdFromFamilyName(string packageFamilyName, ref uint packageNameLength,
|
|
|
|
public static extern Win32Error PackageNameAndPublisherIdFromFamilyName(string packageFamilyName, ref uint packageNameLength,
|
|
|
|
[Optional] StringBuilder packageName, ref uint packagePublisherIdLength, [Optional] StringBuilder packagePublisherId);
|
|
|
|
[Optional] StringBuilder? packageName, ref uint packagePublisherIdLength, [Optional] StringBuilder? packagePublisherId);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// <para>Deconstructs an application user model ID to its package family name and package relative application ID (PRAID).</para>
|
|
|
|
/// <para>Deconstructs an application user model ID to its package family name and package relative application ID (PRAID).</para>
|
|
|
@ -2263,7 +2331,7 @@ namespace Vanara.PInvoke
|
|
|
|
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
|
|
|
[DllImport(Lib.Kernel32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
|
|
|
[PInvokeData("appmodel.h", MSDNShortId = "03B29E82-611F-47D1-8CB6-047B9BEB4D9E")]
|
|
|
|
[PInvokeData("appmodel.h", MSDNShortId = "03B29E82-611F-47D1-8CB6-047B9BEB4D9E")]
|
|
|
|
public static extern Win32Error ParseApplicationUserModelId(string applicationUserModelId, ref uint packageFamilyNameLength,
|
|
|
|
public static extern Win32Error ParseApplicationUserModelId(string applicationUserModelId, ref uint packageFamilyNameLength,
|
|
|
|
[Optional] StringBuilder packageFamilyName, ref uint packageRelativeApplicationIdLength, [Optional] StringBuilder packageRelativeApplicationId);
|
|
|
|
[Optional] StringBuilder? packageFamilyName, ref uint packageRelativeApplicationIdLength, [Optional] StringBuilder? packageRelativeApplicationId);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// Removes a resolved package dependency from the current process' package graph (that is, a run-time reference for a framework
|
|
|
|
/// Removes a resolved package dependency from the current process' package graph (that is, a run-time reference for a framework
|
|
|
@ -2542,7 +2610,7 @@ namespace Vanara.PInvoke
|
|
|
|
public static bool operator ==(PACKAGEDEPENDENCY_CONTEXT h1, PACKAGEDEPENDENCY_CONTEXT h2) => h1.Equals(h2);
|
|
|
|
public static bool operator ==(PACKAGEDEPENDENCY_CONTEXT h1, PACKAGEDEPENDENCY_CONTEXT h2) => h1.Equals(h2);
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public override bool Equals(object obj) => obj is PACKAGEDEPENDENCY_CONTEXT h && handle == h.handle;
|
|
|
|
public override bool Equals(object? obj) => obj is PACKAGEDEPENDENCY_CONTEXT h && handle == h.handle;
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public override int GetHashCode() => handle.GetHashCode();
|
|
|
|
public override int GetHashCode() => handle.GetHashCode();
|
|
|
@ -2550,5 +2618,4 @@ namespace Vanara.PInvoke
|
|
|
|
/// <inheritdoc/>
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public IntPtr DangerousGetHandle() => handle;
|
|
|
|
public IntPtr DangerousGetHandle() => handle;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|