ホーム › System.WinRT.Metadata › RoIsApiContractPresent
RoIsApiContractPresent
関数指定バージョンのAPIコントラクトが存在するかを判定する。
シグネチャ
// api-ms-win-ro-typeresolution-l1-1-1.dll
#include <windows.h>
HRESULT RoIsApiContractPresent(
LPCWSTR name,
WORD majorVersion,
WORD minorVersion,
BOOL* present
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| name | LPCWSTR | in | 存在を確認するAPIコントラクト名(Unicode文字列)。 |
| majorVersion | WORD | in | 確認するコントラクトのメジャーバージョン番号。 |
| minorVersion | WORD | in | 確認するコントラクトのマイナーバージョン番号。 |
| present | BOOL* | out | 出力として指定バージョン以上が存在するか(TRUE/FALSE)を受け取るBOOLポインタ。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// api-ms-win-ro-typeresolution-l1-1-1.dll
#include <windows.h>
HRESULT RoIsApiContractPresent(
LPCWSTR name,
WORD majorVersion,
WORD minorVersion,
BOOL* present
);[DllImport("api-ms-win-ro-typeresolution-l1-1-1.dll", ExactSpelling = true)]
static extern int RoIsApiContractPresent(
[MarshalAs(UnmanagedType.LPWStr)] string name, // LPCWSTR
ushort majorVersion, // WORD
ushort minorVersion, // WORD
out bool present // BOOL* out
);<DllImport("api-ms-win-ro-typeresolution-l1-1-1.dll", ExactSpelling:=True)>
Public Shared Function RoIsApiContractPresent(
<MarshalAs(UnmanagedType.LPWStr)> name As String, ' LPCWSTR
majorVersion As UShort, ' WORD
minorVersion As UShort, ' WORD
<Out> ByRef present As Boolean ' BOOL* out
) As Integer
End Function' name : LPCWSTR
' majorVersion : WORD
' minorVersion : WORD
' present : BOOL* out
Declare PtrSafe Function RoIsApiContractPresent Lib "api-ms-win-ro-typeresolution-l1-1-1" ( _
ByVal name As LongPtr, _
ByVal majorVersion As Integer, _
ByVal minorVersion As Integer, _
ByRef present As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
RoIsApiContractPresent = ctypes.windll.LoadLibrary("api-ms-win-ro-typeresolution-l1-1-1.dll").RoIsApiContractPresent
RoIsApiContractPresent.restype = ctypes.c_int
RoIsApiContractPresent.argtypes = [
wintypes.LPCWSTR, # name : LPCWSTR
ctypes.c_ushort, # majorVersion : WORD
ctypes.c_ushort, # minorVersion : WORD
ctypes.c_void_p, # present : BOOL* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('api-ms-win-ro-typeresolution-l1-1-1.dll')
RoIsApiContractPresent = Fiddle::Function.new(
lib['RoIsApiContractPresent'],
[
Fiddle::TYPE_VOIDP, # name : LPCWSTR
-Fiddle::TYPE_SHORT, # majorVersion : WORD
-Fiddle::TYPE_SHORT, # minorVersion : WORD
Fiddle::TYPE_VOIDP, # present : BOOL* out
],
Fiddle::TYPE_INT)#[link(name = "api-ms-win-ro-typeresolution-l1-1-1")]
extern "system" {
fn RoIsApiContractPresent(
name: *const u16, // LPCWSTR
majorVersion: u16, // WORD
minorVersion: u16, // WORD
present: *mut i32 // BOOL* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("api-ms-win-ro-typeresolution-l1-1-1.dll")]
public static extern int RoIsApiContractPresent([MarshalAs(UnmanagedType.LPWStr)] string name, ushort majorVersion, ushort minorVersion, out bool present);
"@
$api = Add-Type -MemberDefinition $sig -Name 'api-ms-win-ro-typeresolution-l1-1-1_RoIsApiContractPresent' -Namespace Win32 -PassThru
# $api::RoIsApiContractPresent(name, majorVersion, minorVersion, present)#uselib "api-ms-win-ro-typeresolution-l1-1-1.dll"
#func global RoIsApiContractPresent "RoIsApiContractPresent" sptr, sptr, sptr, sptr
; RoIsApiContractPresent name, majorVersion, minorVersion, varptr(present) ; 戻り値は stat
; name : LPCWSTR -> "sptr"
; majorVersion : WORD -> "sptr"
; minorVersion : WORD -> "sptr"
; present : BOOL* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "api-ms-win-ro-typeresolution-l1-1-1.dll" #cfunc global RoIsApiContractPresent "RoIsApiContractPresent" wstr, int, int, var ; res = RoIsApiContractPresent(name, majorVersion, minorVersion, present) ; name : LPCWSTR -> "wstr" ; majorVersion : WORD -> "int" ; minorVersion : WORD -> "int" ; present : BOOL* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "api-ms-win-ro-typeresolution-l1-1-1.dll" #cfunc global RoIsApiContractPresent "RoIsApiContractPresent" wstr, int, int, sptr ; res = RoIsApiContractPresent(name, majorVersion, minorVersion, varptr(present)) ; name : LPCWSTR -> "wstr" ; majorVersion : WORD -> "int" ; minorVersion : WORD -> "int" ; present : BOOL* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT RoIsApiContractPresent(LPCWSTR name, WORD majorVersion, WORD minorVersion, BOOL* present) #uselib "api-ms-win-ro-typeresolution-l1-1-1.dll" #cfunc global RoIsApiContractPresent "RoIsApiContractPresent" wstr, int, int, var ; res = RoIsApiContractPresent(name, majorVersion, minorVersion, present) ; name : LPCWSTR -> "wstr" ; majorVersion : WORD -> "int" ; minorVersion : WORD -> "int" ; present : BOOL* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT RoIsApiContractPresent(LPCWSTR name, WORD majorVersion, WORD minorVersion, BOOL* present) #uselib "api-ms-win-ro-typeresolution-l1-1-1.dll" #cfunc global RoIsApiContractPresent "RoIsApiContractPresent" wstr, int, int, intptr ; res = RoIsApiContractPresent(name, majorVersion, minorVersion, varptr(present)) ; name : LPCWSTR -> "wstr" ; majorVersion : WORD -> "int" ; minorVersion : WORD -> "int" ; present : BOOL* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
api_ms_win_ro_typeresolution_l1_1_1 = windows.NewLazySystemDLL("api-ms-win-ro-typeresolution-l1-1-1.dll")
procRoIsApiContractPresent = api_ms_win_ro_typeresolution_l1_1_1.NewProc("RoIsApiContractPresent")
)
// name (LPCWSTR), majorVersion (WORD), minorVersion (WORD), present (BOOL* out)
r1, _, err := procRoIsApiContractPresent.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(name))),
uintptr(majorVersion),
uintptr(minorVersion),
uintptr(present),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction RoIsApiContractPresent(
name: PWideChar; // LPCWSTR
majorVersion: Word; // WORD
minorVersion: Word; // WORD
present: Pointer // BOOL* out
): Integer; stdcall;
external 'api-ms-win-ro-typeresolution-l1-1-1.dll' name 'RoIsApiContractPresent';result := DllCall("api-ms-win-ro-typeresolution-l1-1-1\RoIsApiContractPresent"
, "WStr", name ; LPCWSTR
, "UShort", majorVersion ; WORD
, "UShort", minorVersion ; WORD
, "Ptr", present ; BOOL* out
, "Int") ; return: HRESULT●RoIsApiContractPresent(name, majorVersion, minorVersion, present) = DLL("api-ms-win-ro-typeresolution-l1-1-1.dll", "int RoIsApiContractPresent(char*, int, int, void*)")
# 呼び出し: RoIsApiContractPresent(name, majorVersion, minorVersion, present)
# name : LPCWSTR -> "char*"
# majorVersion : WORD -> "int"
# minorVersion : WORD -> "int"
# present : BOOL* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "api-ms-win-ro-typeresolution-l1-1-1" fn RoIsApiContractPresent(
name: [*c]const u16, // LPCWSTR
majorVersion: u16, // WORD
minorVersion: u16, // WORD
present: [*c]i32 // BOOL* out
) callconv(std.os.windows.WINAPI) i32;proc RoIsApiContractPresent(
name: WideCString, # LPCWSTR
majorVersion: uint16, # WORD
minorVersion: uint16, # WORD
present: ptr int32 # BOOL* out
): int32 {.importc: "RoIsApiContractPresent", stdcall, dynlib: "api-ms-win-ro-typeresolution-l1-1-1.dll".}pragma(lib, "api-ms-win-ro-typeresolution-l1-1-1");
extern(Windows)
int RoIsApiContractPresent(
const(wchar)* name, // LPCWSTR
ushort majorVersion, // WORD
ushort minorVersion, // WORD
int* present // BOOL* out
);ccall((:RoIsApiContractPresent, "api-ms-win-ro-typeresolution-l1-1-1.dll"), stdcall, Int32,
(Cwstring, UInt16, UInt16, Ptr{Int32}),
name, majorVersion, minorVersion, present)
# name : LPCWSTR -> Cwstring
# majorVersion : WORD -> UInt16
# minorVersion : WORD -> UInt16
# present : BOOL* out -> Ptr{Int32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t RoIsApiContractPresent(
const uint16_t* name,
uint16_t majorVersion,
uint16_t minorVersion,
int32_t* present);
]]
local api-ms-win-ro-typeresolution-l1-1-1 = ffi.load("api-ms-win-ro-typeresolution-l1-1-1")
-- api-ms-win-ro-typeresolution-l1-1-1.RoIsApiContractPresent(name, majorVersion, minorVersion, present)
-- name : LPCWSTR
-- majorVersion : WORD
-- minorVersion : WORD
-- present : BOOL* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('api-ms-win-ro-typeresolution-l1-1-1.dll');
const RoIsApiContractPresent = lib.func('__stdcall', 'RoIsApiContractPresent', 'int32_t', ['str16', 'uint16_t', 'uint16_t', 'int32_t *']);
// RoIsApiContractPresent(name, majorVersion, minorVersion, present)
// name : LPCWSTR -> 'str16'
// majorVersion : WORD -> 'uint16_t'
// minorVersion : WORD -> 'uint16_t'
// present : BOOL* out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("api-ms-win-ro-typeresolution-l1-1-1.dll", {
RoIsApiContractPresent: { parameters: ["buffer", "u16", "u16", "pointer"], result: "i32" },
});
// lib.symbols.RoIsApiContractPresent(name, majorVersion, minorVersion, present)
// name : LPCWSTR -> "buffer"
// majorVersion : WORD -> "u16"
// minorVersion : WORD -> "u16"
// present : BOOL* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t RoIsApiContractPresent(
const uint16_t* name,
uint16_t majorVersion,
uint16_t minorVersion,
int32_t* present);
C, "api-ms-win-ro-typeresolution-l1-1-1.dll");
// $ffi->RoIsApiContractPresent(name, majorVersion, minorVersion, present);
// name : LPCWSTR
// majorVersion : WORD
// minorVersion : WORD
// present : BOOL* out
// 構造体/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-ro-typeresolution-l1-1-1 extends StdCallLibrary {
Api-ms-win-ro-typeresolution-l1-1-1 INSTANCE = Native.load("api-ms-win-ro-typeresolution-l1-1-1", Api-ms-win-ro-typeresolution-l1-1-1.class);
int RoIsApiContractPresent(
WString name, // LPCWSTR
short majorVersion, // WORD
short minorVersion, // WORD
IntByReference present // BOOL* out
);
}@[Link("api-ms-win-ro-typeresolution-l1-1-1")]
lib Libapi-ms-win-ro-typeresolution-l1-1-1
fun RoIsApiContractPresent = RoIsApiContractPresent(
name : UInt16*, # LPCWSTR
majorVersion : UInt16, # WORD
minorVersion : UInt16, # WORD
present : Int32* # BOOL* out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef RoIsApiContractPresentNative = Int32 Function(Pointer<Utf16>, Uint16, Uint16, Pointer<Int32>);
typedef RoIsApiContractPresentDart = int Function(Pointer<Utf16>, int, int, Pointer<Int32>);
final RoIsApiContractPresent = DynamicLibrary.open('api-ms-win-ro-typeresolution-l1-1-1.dll')
.lookupFunction<RoIsApiContractPresentNative, RoIsApiContractPresentDart>('RoIsApiContractPresent');
// name : LPCWSTR -> Pointer<Utf16>
// majorVersion : WORD -> Uint16
// minorVersion : WORD -> Uint16
// present : BOOL* out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function RoIsApiContractPresent(
name: PWideChar; // LPCWSTR
majorVersion: Word; // WORD
minorVersion: Word; // WORD
present: Pointer // BOOL* out
): Integer; stdcall;
external 'api-ms-win-ro-typeresolution-l1-1-1.dll' name 'RoIsApiContractPresent';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "RoIsApiContractPresent"
c_RoIsApiContractPresent :: CWString -> Word16 -> Word16 -> Ptr CInt -> IO Int32
-- name : LPCWSTR -> CWString
-- majorVersion : WORD -> Word16
-- minorVersion : WORD -> Word16
-- present : BOOL* out -> Ptr CInt
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let roisapicontractpresent =
foreign "RoIsApiContractPresent"
((ptr uint16_t) @-> uint16_t @-> uint16_t @-> (ptr int32_t) @-> returning int32_t)
(* name : LPCWSTR -> (ptr uint16_t) *)
(* majorVersion : WORD -> uint16_t *)
(* minorVersion : WORD -> uint16_t *)
(* present : BOOL* out -> (ptr int32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library api-ms-win-ro-typeresolution-l1-1-1 (t "api-ms-win-ro-typeresolution-l1-1-1.dll"))
(cffi:use-foreign-library api-ms-win-ro-typeresolution-l1-1-1)
(cffi:defcfun ("RoIsApiContractPresent" ro-is-api-contract-present :convention :stdcall) :int32
(name (:string :encoding :utf-16le)) ; LPCWSTR
(major-version :uint16) ; WORD
(minor-version :uint16) ; WORD
(present :pointer)) ; BOOL* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $RoIsApiContractPresent = Win32::API::More->new('api-ms-win-ro-typeresolution-l1-1-1',
'int RoIsApiContractPresent(LPCWSTR name, WORD majorVersion, WORD minorVersion, LPVOID present)');
# my $ret = $RoIsApiContractPresent->Call($name, $majorVersion, $minorVersion, $present);
# name : LPCWSTR -> LPCWSTR
# majorVersion : WORD -> WORD
# minorVersion : WORD -> WORD
# present : BOOL* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。