using System.Runtime.InteropServices; namespace Vanara.PInvoke { public static partial class Kernel32 { /// The IsApiSetImplemented function tests if a specified API set is present on the computer. /// Specifies the name of the API set to query. For more info, see the Remarks section. /// /// /// IsApiSetImplemented returns TRUE if the specified API set is present. In this case, APIs in the target API set /// have valid implementations on the current platform. /// /// Otherwise, this function returns FALSE. /// /// /// /// On OneCore, APIs are organized into functional groups called API sets. Depending on applicability, a given API set may be /// unavailable on the target platform. /// /// /// When writing code that targets OneCore and Desktop platforms, you may see ApiValidator errors during compilation if your code /// calls APIs from API sets not present on the computer. /// /// /// To fix this problem, wrap the API call in IsApiSetImplemented. This function tests at runtime if the specified API set is /// present on the target platform. /// /// /// To determine the API set for a given API, find the API name on the OneCoreUap umbrella library page and remove the suffix from /// the requirements entry. /// /// By making use of IsApiSetImplemented, you can target OneCore and Desktop systems with a single binary. /// /// You don't need to call IsApiSetImplemented for universal APIs because they are by definition present on both OneCore and /// Desktop versions of Windows. /// /// /// See the corresponding API reference documentation pages to determine if a given API is universally available. Look for the /// Target Platform line in the requirements block of the documentation page. /// /// For more information and examples of usage, see Building for OneCore. /// // https://docs.microsoft.com/en-us/windows/win32/api/apiquery2/nf-apiquery2-isapisetimplemented APICONTRACT BOOL // IsApiSetImplemented( PCSTR Contract ); [DllImport(Lib.KernelBase, SetLastError = false, ExactSpelling = true)] [PInvokeData("apiquery2.h", MSDNShortId = "DF177716-9F33-4E39-BD63-D1B8E39CD67C")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool IsApiSetImplemented([MarshalAs(UnmanagedType.LPStr)] string Contract); } }