IsApiSetImplemented
関数シグネチャ
// api-ms-win-core-apiquery-l2-1-0.dll
#include <windows.h>
BOOL IsApiSetImplemented(
LPCSTR Contract
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| Contract | LPCSTR | in | クエリする API セットの名前を指定します。詳細については、「解説」セクションを参照してください。 |
戻り値の型: BOOL
公式ドキュメント
IsApiSetImplemented 関数は、指定した API セットがコンピューター上に存在するかどうかをテストします。
戻り値
IsApiSetImplemented は、指定した API セットが存在する場合に TRUE を返します。この場合、対象の API セット内の API は現在のプラットフォーム上で有効な実装を持ちます。
それ以外の場合、この関数は FALSE を返します。
解説(Remarks)
Windows 10 のすべてのバージョンは、コア OS(コンテキストによっては OneCore とも呼ばれます)と呼ばれる OS コンポーネントの共通基盤を共有しています。コア OS コンポーネントでは、Win32 API は API セット と呼ばれる機能グループに編成されています。
一部の API セットは、すべての Windows 10 プラットフォームで利用できるわけではありません。たとえば、PC では Win32 API の全範囲がサポートされますが、HoloLens、Xbox、および Windows 10x を実行するその他のデバイスでは、Win32 API の一部のみが利用可能です。
デスクトップと非デスクトップの両方の Windows 10 デバイスを対象とするコードを記述する場合は、API 呼び出しを IsApiSetImplemented でラップしてください。この関数は、その API が属する API セットが対象プラットフォームに存在するかどうかを実行時にテストします。詳細については、「API セットの可用性を検出する」を参照してください。
特定の Win32 API が API セットに属しているかどうかを確認するには、その API のリファレンス ドキュメントにある要件テーブルを参照してください。API が API セットに属している場合、その記事の要件テーブルに API セット名が記載されています。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// api-ms-win-core-apiquery-l2-1-0.dll
#include <windows.h>
BOOL IsApiSetImplemented(
LPCSTR Contract
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("api-ms-win-core-apiquery-l2-1-0.dll", ExactSpelling = true)]
static extern bool IsApiSetImplemented(
[MarshalAs(UnmanagedType.LPStr)] string Contract // LPCSTR
);<DllImport("api-ms-win-core-apiquery-l2-1-0.dll", ExactSpelling:=True)>
Public Shared Function IsApiSetImplemented(
<MarshalAs(UnmanagedType.LPStr)> Contract As String ' LPCSTR
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' Contract : LPCSTR
Declare PtrSafe Function IsApiSetImplemented Lib "api-ms-win-core-apiquery-l2-1-0" ( _
ByVal Contract As String) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
IsApiSetImplemented = ctypes.windll.LoadLibrary("api-ms-win-core-apiquery-l2-1-0.dll").IsApiSetImplemented
IsApiSetImplemented.restype = wintypes.BOOL
IsApiSetImplemented.argtypes = [
wintypes.LPCSTR, # Contract : LPCSTR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('api-ms-win-core-apiquery-l2-1-0.dll')
IsApiSetImplemented = Fiddle::Function.new(
lib['IsApiSetImplemented'],
[
Fiddle::TYPE_VOIDP, # Contract : LPCSTR
],
Fiddle::TYPE_INT)#[link(name = "api-ms-win-core-apiquery-l2-1-0")]
extern "system" {
fn IsApiSetImplemented(
Contract: *const u8 // LPCSTR
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("api-ms-win-core-apiquery-l2-1-0.dll")]
public static extern bool IsApiSetImplemented([MarshalAs(UnmanagedType.LPStr)] string Contract);
"@
$api = Add-Type -MemberDefinition $sig -Name 'api-ms-win-core-apiquery-l2-1-0_IsApiSetImplemented' -Namespace Win32 -PassThru
# $api::IsApiSetImplemented(Contract)#uselib "api-ms-win-core-apiquery-l2-1-0.dll"
#func global IsApiSetImplemented "IsApiSetImplemented" sptr
; IsApiSetImplemented Contract ; 戻り値は stat
; Contract : LPCSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "api-ms-win-core-apiquery-l2-1-0.dll"
#cfunc global IsApiSetImplemented "IsApiSetImplemented" str
; res = IsApiSetImplemented(Contract)
; Contract : LPCSTR -> "str"; BOOL IsApiSetImplemented(LPCSTR Contract)
#uselib "api-ms-win-core-apiquery-l2-1-0.dll"
#cfunc global IsApiSetImplemented "IsApiSetImplemented" str
; res = IsApiSetImplemented(Contract)
; Contract : LPCSTR -> "str"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
api_ms_win_core_apiquery_l2_1_0 = windows.NewLazySystemDLL("api-ms-win-core-apiquery-l2-1-0.dll")
procIsApiSetImplemented = api_ms_win_core_apiquery_l2_1_0.NewProc("IsApiSetImplemented")
)
// Contract (LPCSTR)
r1, _, err := procIsApiSetImplemented.Call(
uintptr(unsafe.Pointer(windows.BytePtrFromString(Contract))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction IsApiSetImplemented(
Contract: PAnsiChar // LPCSTR
): BOOL; stdcall;
external 'api-ms-win-core-apiquery-l2-1-0.dll' name 'IsApiSetImplemented';result := DllCall("api-ms-win-core-apiquery-l2-1-0\IsApiSetImplemented"
, "AStr", Contract ; LPCSTR
, "Int") ; return: BOOL●IsApiSetImplemented(Contract) = DLL("api-ms-win-core-apiquery-l2-1-0.dll", "bool IsApiSetImplemented(char*)")
# 呼び出し: IsApiSetImplemented(Contract)
# Contract : LPCSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "api-ms-win-core-apiquery-l2-1-0" fn IsApiSetImplemented(
Contract: [*c]const u8 // LPCSTR
) callconv(std.os.windows.WINAPI) i32;proc IsApiSetImplemented(
Contract: cstring # LPCSTR
): int32 {.importc: "IsApiSetImplemented", stdcall, dynlib: "api-ms-win-core-apiquery-l2-1-0.dll".}pragma(lib, "api-ms-win-core-apiquery-l2-1-0");
extern(Windows)
int IsApiSetImplemented(
const(char)* Contract // LPCSTR
);ccall((:IsApiSetImplemented, "api-ms-win-core-apiquery-l2-1-0.dll"), stdcall, Int32,
(Cstring,),
Contract)
# Contract : LPCSTR -> Cstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t IsApiSetImplemented(
const char* Contract);
]]
local api-ms-win-core-apiquery-l2-1-0 = ffi.load("api-ms-win-core-apiquery-l2-1-0")
-- api-ms-win-core-apiquery-l2-1-0.IsApiSetImplemented(Contract)
-- Contract : LPCSTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('api-ms-win-core-apiquery-l2-1-0.dll');
const IsApiSetImplemented = lib.func('__stdcall', 'IsApiSetImplemented', 'int32_t', ['str']);
// IsApiSetImplemented(Contract)
// Contract : LPCSTR -> 'str'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("api-ms-win-core-apiquery-l2-1-0.dll", {
IsApiSetImplemented: { parameters: ["buffer"], result: "i32" },
});
// lib.symbols.IsApiSetImplemented(Contract)
// Contract : LPCSTR -> "buffer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t IsApiSetImplemented(
const char* Contract);
C, "api-ms-win-core-apiquery-l2-1-0.dll");
// $ffi->IsApiSetImplemented(Contract);
// Contract : LPCSTR
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Api-ms-win-core-apiquery-l2-1-0 extends StdCallLibrary {
Api-ms-win-core-apiquery-l2-1-0 INSTANCE = Native.load("api-ms-win-core-apiquery-l2-1-0", Api-ms-win-core-apiquery-l2-1-0.class);
boolean IsApiSetImplemented(
String Contract // LPCSTR
);
}@[Link("api-ms-win-core-apiquery-l2-1-0")]
lib Libapi-ms-win-core-apiquery-l2-1-0
fun IsApiSetImplemented = IsApiSetImplemented(
Contract : UInt8* # LPCSTR
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef IsApiSetImplementedNative = Int32 Function(Pointer<Utf8>);
typedef IsApiSetImplementedDart = int Function(Pointer<Utf8>);
final IsApiSetImplemented = DynamicLibrary.open('api-ms-win-core-apiquery-l2-1-0.dll')
.lookupFunction<IsApiSetImplementedNative, IsApiSetImplementedDart>('IsApiSetImplemented');
// Contract : LPCSTR -> Pointer<Utf8>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function IsApiSetImplemented(
Contract: PAnsiChar // LPCSTR
): BOOL; stdcall;
external 'api-ms-win-core-apiquery-l2-1-0.dll' name 'IsApiSetImplemented';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "IsApiSetImplemented"
c_IsApiSetImplemented :: CString -> IO CInt
-- Contract : LPCSTR -> CString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let isapisetimplemented =
foreign "IsApiSetImplemented"
(string @-> returning int32_t)
(* Contract : LPCSTR -> string *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library api-ms-win-core-apiquery-l2-1-0 (t "api-ms-win-core-apiquery-l2-1-0.dll"))
(cffi:use-foreign-library api-ms-win-core-apiquery-l2-1-0)
(cffi:defcfun ("IsApiSetImplemented" is-api-set-implemented :convention :stdcall) :int32
(contract :string)) ; LPCSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $IsApiSetImplemented = Win32::API::More->new('api-ms-win-core-apiquery-l2-1-0',
'BOOL IsApiSetImplemented(LPCSTR Contract)');
# my $ret = $IsApiSetImplemented->Call($Contract);
# Contract : LPCSTR -> LPCSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。