mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 03:07:04 +02:00
<!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Summary of the Pull Request This PR introduces necessary changes to make the CmdPal.Apps extension compatible with NativeAOT publishing. The main updates include: 1. Project configuration updates: Added NativeAOT-related properties to the .csproj. 2. Native interop adjustments: > - Introduced NativeMethods.json and used [CsWin32](https://github.com/microsoft/cswin32) to generate P/Invoke bindings. > - Replaced some DllImport declarations with source-generated [LibraryImport] for improved AOT support.
31 lines
732 B
C#
31 lines
732 B
C#
// Copyright (c) Microsoft Corporation
|
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
using System;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace Microsoft.CmdPal.Ext.Apps.Utils;
|
|
|
|
public partial class SafeComHandle : SafeHandle
|
|
{
|
|
public SafeComHandle()
|
|
: base(IntPtr.Zero, ownsHandle: true)
|
|
{
|
|
}
|
|
|
|
public SafeComHandle(IntPtr handle)
|
|
: base(IntPtr.Zero, ownsHandle: true)
|
|
{
|
|
SetHandle(handle);
|
|
}
|
|
|
|
public override bool IsInvalid => handle == IntPtr.Zero;
|
|
|
|
protected override bool ReleaseHandle()
|
|
{
|
|
var count = Marshal.Release(handle);
|
|
return true;
|
|
}
|
|
}
|