From 9ecd87768e3e2300bbc4a16c7ee3ce5b3ce7de10 Mon Sep 17 00:00:00 2001 From: gumbarros Date: Fri, 3 May 2024 22:18:32 -0300 Subject: [PATCH] Use `LibraryImportAttribute` at undocumented EntryPoint #865 --- src/Files.App/Helpers/Environment/ElevationHelpers.cs | 3 +-- src/Files.App/Helpers/Win32/Win32PInvoke.Methods.cs | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Files.App/Helpers/Environment/ElevationHelpers.cs b/src/Files.App/Helpers/Environment/ElevationHelpers.cs index 6902d8d4427a..2770e09eb7ae 100644 --- a/src/Files.App/Helpers/Environment/ElevationHelpers.cs +++ b/src/Files.App/Helpers/Environment/ElevationHelpers.cs @@ -1,7 +1,6 @@ // Copyright (c) 2024 Files Community // Licensed under the MIT License. See the LICENSE. -using System.Runtime.InteropServices; using System.Security.Principal; namespace Files.App.Helpers @@ -13,7 +12,7 @@ public static bool IsElevationRequired(string filePath) if (string.IsNullOrEmpty(filePath)) return false; - return Win32PInvoke._IsElevationRequired(filePath); + return Win32PInvoke.IsElevationRequired(filePath); } public static bool IsAppRunAsAdmin() diff --git a/src/Files.App/Helpers/Win32/Win32PInvoke.Methods.cs b/src/Files.App/Helpers/Win32/Win32PInvoke.Methods.cs index d29372187247..880969daf21e 100644 --- a/src/Files.App/Helpers/Win32/Win32PInvoke.Methods.cs +++ b/src/Files.App/Helpers/Win32/Win32PInvoke.Methods.cs @@ -426,9 +426,9 @@ public static extern int CompareStringEx( int param ); - [DllImport("shell32.dll", EntryPoint = "#865", CharSet = CharSet.Unicode, SetLastError = true)] + [LibraryImport("shell32.dll", EntryPoint = "#865", SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool _IsElevationRequired( + public static partial bool IsElevationRequired( [MarshalAs(UnmanagedType.LPWStr)] string pszPath); [DllImport("shlwapi.dll", CallingConvention = CallingConvention.StdCall, PreserveSig = true, CharSet = CharSet.Unicode)]