Win32 API 日本語リファレンス
ホームNetworking.WindowsWebServices › WsMatchPolicyAlternative

WsMatchPolicyAlternative

関数
ポリシーの代替候補が制約に一致するか照合する。
DLLwebservices.dll呼出規約winapi対応OSWindows 7 以降

シグネチャ

// webservices.dll
#include <windows.h>

HRESULT WsMatchPolicyAlternative(
    WS_POLICY* policy,
    DWORD alternativeIndex,
    WS_POLICY_CONSTRAINTS* policyConstraints,
    BOOL matchRequired,
    WS_HEAP* heap,
    WS_ERROR* error   // optional
);

パラメーター

名前方向説明
policyWS_POLICY*in照合対象のWS_POLICYオブジェクト。
alternativeIndexDWORDin照合するポリシー代替案の0始まりインデックス。
policyConstraintsWS_POLICY_CONSTRAINTS*inクライアントが満たせる制約を示すWS_POLICY_CONSTRAINTS。
matchRequiredBOOLin不一致時にエラーを返すかを示すBOOL。TRUEで必須照合とする。
heapWS_HEAP*in照合結果の確保に使うWS_HEAP。
errorWS_ERROR*inoptional詳細なエラー情報を格納するWS_ERRORオブジェクト。NULL可。

戻り値の型: HRESULT

各言語での呼び出し定義

// webservices.dll
#include <windows.h>

HRESULT WsMatchPolicyAlternative(
    WS_POLICY* policy,
    DWORD alternativeIndex,
    WS_POLICY_CONSTRAINTS* policyConstraints,
    BOOL matchRequired,
    WS_HEAP* heap,
    WS_ERROR* error   // optional
);
[DllImport("webservices.dll", ExactSpelling = true)]
static extern int WsMatchPolicyAlternative(
    ref IntPtr policy,   // WS_POLICY*
    uint alternativeIndex,   // DWORD
    IntPtr policyConstraints,   // WS_POLICY_CONSTRAINTS*
    bool matchRequired,   // BOOL
    ref IntPtr heap,   // WS_HEAP*
    IntPtr error   // WS_ERROR* optional
);
<DllImport("webservices.dll", ExactSpelling:=True)>
Public Shared Function WsMatchPolicyAlternative(
    ByRef policy As IntPtr,   ' WS_POLICY*
    alternativeIndex As UInteger,   ' DWORD
    policyConstraints As IntPtr,   ' WS_POLICY_CONSTRAINTS*
    matchRequired As Boolean,   ' BOOL
    ByRef heap As IntPtr,   ' WS_HEAP*
    [error] As IntPtr   ' WS_ERROR* optional
) As Integer
End Function
' policy : WS_POLICY*
' alternativeIndex : DWORD
' policyConstraints : WS_POLICY_CONSTRAINTS*
' matchRequired : BOOL
' heap : WS_HEAP*
' error : WS_ERROR* optional
Declare PtrSafe Function WsMatchPolicyAlternative Lib "webservices" ( _
    ByRef policy As LongPtr, _
    ByVal alternativeIndex As Long, _
    ByVal policyConstraints As LongPtr, _
    ByVal matchRequired As Long, _
    ByRef heap As LongPtr, _
    ByVal error As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WsMatchPolicyAlternative = ctypes.windll.webservices.WsMatchPolicyAlternative
WsMatchPolicyAlternative.restype = ctypes.c_int
WsMatchPolicyAlternative.argtypes = [
    ctypes.c_void_p,  # policy : WS_POLICY*
    wintypes.DWORD,  # alternativeIndex : DWORD
    ctypes.c_void_p,  # policyConstraints : WS_POLICY_CONSTRAINTS*
    wintypes.BOOL,  # matchRequired : BOOL
    ctypes.c_void_p,  # heap : WS_HEAP*
    ctypes.c_void_p,  # error : WS_ERROR* optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('webservices.dll')
WsMatchPolicyAlternative = Fiddle::Function.new(
  lib['WsMatchPolicyAlternative'],
  [
    Fiddle::TYPE_VOIDP,  # policy : WS_POLICY*
    -Fiddle::TYPE_INT,  # alternativeIndex : DWORD
    Fiddle::TYPE_VOIDP,  # policyConstraints : WS_POLICY_CONSTRAINTS*
    Fiddle::TYPE_INT,  # matchRequired : BOOL
    Fiddle::TYPE_VOIDP,  # heap : WS_HEAP*
    Fiddle::TYPE_VOIDP,  # error : WS_ERROR* optional
  ],
  Fiddle::TYPE_INT)
#[link(name = "webservices")]
extern "system" {
    fn WsMatchPolicyAlternative(
        policy: *mut isize,  // WS_POLICY*
        alternativeIndex: u32,  // DWORD
        policyConstraints: *mut WS_POLICY_CONSTRAINTS,  // WS_POLICY_CONSTRAINTS*
        matchRequired: i32,  // BOOL
        heap: *mut isize,  // WS_HEAP*
        error: *mut isize  // WS_ERROR* optional
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("webservices.dll")]
public static extern int WsMatchPolicyAlternative(ref IntPtr policy, uint alternativeIndex, IntPtr policyConstraints, bool matchRequired, ref IntPtr heap, IntPtr error);
"@
$api = Add-Type -MemberDefinition $sig -Name 'webservices_WsMatchPolicyAlternative' -Namespace Win32 -PassThru
# $api::WsMatchPolicyAlternative(policy, alternativeIndex, policyConstraints, matchRequired, heap, error)
#uselib "webservices.dll"
#func global WsMatchPolicyAlternative "WsMatchPolicyAlternative" sptr, sptr, sptr, sptr, sptr, sptr
; WsMatchPolicyAlternative varptr(policy), alternativeIndex, varptr(policyConstraints), matchRequired, varptr(heap), varptr(error)   ; 戻り値は stat
; policy : WS_POLICY* -> "sptr"
; alternativeIndex : DWORD -> "sptr"
; policyConstraints : WS_POLICY_CONSTRAINTS* -> "sptr"
; matchRequired : BOOL -> "sptr"
; heap : WS_HEAP* -> "sptr"
; error : WS_ERROR* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "webservices.dll"
#cfunc global WsMatchPolicyAlternative "WsMatchPolicyAlternative" var, int, var, int, var, var
; res = WsMatchPolicyAlternative(policy, alternativeIndex, policyConstraints, matchRequired, heap, error)
; policy : WS_POLICY* -> "var"
; alternativeIndex : DWORD -> "int"
; policyConstraints : WS_POLICY_CONSTRAINTS* -> "var"
; matchRequired : BOOL -> "int"
; heap : WS_HEAP* -> "var"
; error : WS_ERROR* optional -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT WsMatchPolicyAlternative(WS_POLICY* policy, DWORD alternativeIndex, WS_POLICY_CONSTRAINTS* policyConstraints, BOOL matchRequired, WS_HEAP* heap, WS_ERROR* error)
#uselib "webservices.dll"
#cfunc global WsMatchPolicyAlternative "WsMatchPolicyAlternative" var, int, var, int, var, var
; res = WsMatchPolicyAlternative(policy, alternativeIndex, policyConstraints, matchRequired, heap, error)
; policy : WS_POLICY* -> "var"
; alternativeIndex : DWORD -> "int"
; policyConstraints : WS_POLICY_CONSTRAINTS* -> "var"
; matchRequired : BOOL -> "int"
; heap : WS_HEAP* -> "var"
; error : WS_ERROR* optional -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	webservices = windows.NewLazySystemDLL("webservices.dll")
	procWsMatchPolicyAlternative = webservices.NewProc("WsMatchPolicyAlternative")
)

// policy (WS_POLICY*), alternativeIndex (DWORD), policyConstraints (WS_POLICY_CONSTRAINTS*), matchRequired (BOOL), heap (WS_HEAP*), error (WS_ERROR* optional)
r1, _, err := procWsMatchPolicyAlternative.Call(
	uintptr(policy),
	uintptr(alternativeIndex),
	uintptr(policyConstraints),
	uintptr(matchRequired),
	uintptr(heap),
	uintptr(error),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function WsMatchPolicyAlternative(
  policy: Pointer;   // WS_POLICY*
  alternativeIndex: DWORD;   // DWORD
  policyConstraints: Pointer;   // WS_POLICY_CONSTRAINTS*
  matchRequired: BOOL;   // BOOL
  heap: Pointer;   // WS_HEAP*
  error: Pointer   // WS_ERROR* optional
): Integer; stdcall;
  external 'webservices.dll' name 'WsMatchPolicyAlternative';
result := DllCall("webservices\WsMatchPolicyAlternative"
    , "Ptr", policy   ; WS_POLICY*
    , "UInt", alternativeIndex   ; DWORD
    , "Ptr", policyConstraints   ; WS_POLICY_CONSTRAINTS*
    , "Int", matchRequired   ; BOOL
    , "Ptr", heap   ; WS_HEAP*
    , "Ptr", error   ; WS_ERROR* optional
    , "Int")   ; return: HRESULT
●WsMatchPolicyAlternative(policy, alternativeIndex, policyConstraints, matchRequired, heap, error) = DLL("webservices.dll", "int WsMatchPolicyAlternative(void*, dword, void*, bool, void*, void*)")
# 呼び出し: WsMatchPolicyAlternative(policy, alternativeIndex, policyConstraints, matchRequired, heap, error)
# policy : WS_POLICY* -> "void*"
# alternativeIndex : DWORD -> "dword"
# policyConstraints : WS_POLICY_CONSTRAINTS* -> "void*"
# matchRequired : BOOL -> "bool"
# heap : WS_HEAP* -> "void*"
# error : WS_ERROR* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "webservices" fn WsMatchPolicyAlternative(
    policy: [*c]isize, // WS_POLICY*
    alternativeIndex: u32, // DWORD
    policyConstraints: [*c]WS_POLICY_CONSTRAINTS, // WS_POLICY_CONSTRAINTS*
    matchRequired: i32, // BOOL
    heap: [*c]isize, // WS_HEAP*
    error: [*c]isize // WS_ERROR* optional
) callconv(std.os.windows.WINAPI) i32;
proc WsMatchPolicyAlternative(
    policy: ptr int,  # WS_POLICY*
    alternativeIndex: uint32,  # DWORD
    policyConstraints: ptr WS_POLICY_CONSTRAINTS,  # WS_POLICY_CONSTRAINTS*
    matchRequired: int32,  # BOOL
    heap: ptr int,  # WS_HEAP*
    error: ptr int  # WS_ERROR* optional
): int32 {.importc: "WsMatchPolicyAlternative", stdcall, dynlib: "webservices.dll".}
pragma(lib, "webservices");
extern(Windows)
int WsMatchPolicyAlternative(
    ptrdiff_t* policy,   // WS_POLICY*
    uint alternativeIndex,   // DWORD
    WS_POLICY_CONSTRAINTS* policyConstraints,   // WS_POLICY_CONSTRAINTS*
    int matchRequired,   // BOOL
    ptrdiff_t* heap,   // WS_HEAP*
    ptrdiff_t* error   // WS_ERROR* optional
);
ccall((:WsMatchPolicyAlternative, "webservices.dll"), stdcall, Int32,
      (Ptr{Int}, UInt32, Ptr{WS_POLICY_CONSTRAINTS}, Int32, Ptr{Int}, Ptr{Int}),
      policy, alternativeIndex, policyConstraints, matchRequired, heap, error)
# policy : WS_POLICY* -> Ptr{Int}
# alternativeIndex : DWORD -> UInt32
# policyConstraints : WS_POLICY_CONSTRAINTS* -> Ptr{WS_POLICY_CONSTRAINTS}
# matchRequired : BOOL -> Int32
# heap : WS_HEAP* -> Ptr{Int}
# error : WS_ERROR* optional -> Ptr{Int}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t WsMatchPolicyAlternative(
    intptr_t* policy,
    uint32_t alternativeIndex,
    void* policyConstraints,
    int32_t matchRequired,
    intptr_t* heap,
    intptr_t* error);
]]
local webservices = ffi.load("webservices")
-- webservices.WsMatchPolicyAlternative(policy, alternativeIndex, policyConstraints, matchRequired, heap, error)
-- policy : WS_POLICY*
-- alternativeIndex : DWORD
-- policyConstraints : WS_POLICY_CONSTRAINTS*
-- matchRequired : BOOL
-- heap : WS_HEAP*
-- error : WS_ERROR* optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('webservices.dll');
const WsMatchPolicyAlternative = lib.func('__stdcall', 'WsMatchPolicyAlternative', 'int32_t', ['intptr_t *', 'uint32_t', 'void *', 'int32_t', 'intptr_t *', 'intptr_t *']);
// WsMatchPolicyAlternative(policy, alternativeIndex, policyConstraints, matchRequired, heap, error)
// policy : WS_POLICY* -> 'intptr_t *'
// alternativeIndex : DWORD -> 'uint32_t'
// policyConstraints : WS_POLICY_CONSTRAINTS* -> 'void *'
// matchRequired : BOOL -> 'int32_t'
// heap : WS_HEAP* -> 'intptr_t *'
// error : WS_ERROR* optional -> 'intptr_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("webservices.dll", {
  WsMatchPolicyAlternative: { parameters: ["pointer", "u32", "pointer", "i32", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.WsMatchPolicyAlternative(policy, alternativeIndex, policyConstraints, matchRequired, heap, error)
// policy : WS_POLICY* -> "pointer"
// alternativeIndex : DWORD -> "u32"
// policyConstraints : WS_POLICY_CONSTRAINTS* -> "pointer"
// matchRequired : BOOL -> "i32"
// heap : WS_HEAP* -> "pointer"
// error : WS_ERROR* optional -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t WsMatchPolicyAlternative(
    intptr_t* policy,
    uint32_t alternativeIndex,
    void* policyConstraints,
    int32_t matchRequired,
    intptr_t* heap,
    intptr_t* error);
C, "webservices.dll");
// $ffi->WsMatchPolicyAlternative(policy, alternativeIndex, policyConstraints, matchRequired, heap, error);
// policy : WS_POLICY*
// alternativeIndex : DWORD
// policyConstraints : WS_POLICY_CONSTRAINTS*
// matchRequired : BOOL
// heap : WS_HEAP*
// error : WS_ERROR* optional
// 構造体/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 Webservices extends StdCallLibrary {
    Webservices INSTANCE = Native.load("webservices", Webservices.class);
    int WsMatchPolicyAlternative(
        LongByReference policy,   // WS_POLICY*
        int alternativeIndex,   // DWORD
        Pointer policyConstraints,   // WS_POLICY_CONSTRAINTS*
        boolean matchRequired,   // BOOL
        LongByReference heap,   // WS_HEAP*
        LongByReference error   // WS_ERROR* optional
    );
}
@[Link("webservices")]
lib Libwebservices
  fun WsMatchPolicyAlternative = WsMatchPolicyAlternative(
    policy : LibC::SSizeT*,   # WS_POLICY*
    alternativeIndex : UInt32,   # DWORD
    policyConstraints : WS_POLICY_CONSTRAINTS*,   # WS_POLICY_CONSTRAINTS*
    matchRequired : Int32,   # BOOL
    heap : LibC::SSizeT*,   # WS_HEAP*
    error : LibC::SSizeT*   # WS_ERROR* optional
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef WsMatchPolicyAlternativeNative = Int32 Function(Pointer<IntPtr>, Uint32, Pointer<Void>, Int32, Pointer<IntPtr>, Pointer<IntPtr>);
typedef WsMatchPolicyAlternativeDart = int Function(Pointer<IntPtr>, int, Pointer<Void>, int, Pointer<IntPtr>, Pointer<IntPtr>);
final WsMatchPolicyAlternative = DynamicLibrary.open('webservices.dll')
    .lookupFunction<WsMatchPolicyAlternativeNative, WsMatchPolicyAlternativeDart>('WsMatchPolicyAlternative');
// policy : WS_POLICY* -> Pointer<IntPtr>
// alternativeIndex : DWORD -> Uint32
// policyConstraints : WS_POLICY_CONSTRAINTS* -> Pointer<Void>
// matchRequired : BOOL -> Int32
// heap : WS_HEAP* -> Pointer<IntPtr>
// error : WS_ERROR* optional -> Pointer<IntPtr>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function WsMatchPolicyAlternative(
  policy: Pointer;   // WS_POLICY*
  alternativeIndex: DWORD;   // DWORD
  policyConstraints: Pointer;   // WS_POLICY_CONSTRAINTS*
  matchRequired: BOOL;   // BOOL
  heap: Pointer;   // WS_HEAP*
  error: Pointer   // WS_ERROR* optional
): Integer; stdcall;
  external 'webservices.dll' name 'WsMatchPolicyAlternative';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "WsMatchPolicyAlternative"
  c_WsMatchPolicyAlternative :: Ptr CIntPtr -> Word32 -> Ptr () -> CInt -> Ptr CIntPtr -> Ptr CIntPtr -> IO Int32
-- policy : WS_POLICY* -> Ptr CIntPtr
-- alternativeIndex : DWORD -> Word32
-- policyConstraints : WS_POLICY_CONSTRAINTS* -> Ptr ()
-- matchRequired : BOOL -> CInt
-- heap : WS_HEAP* -> Ptr CIntPtr
-- error : WS_ERROR* optional -> Ptr CIntPtr
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let wsmatchpolicyalternative =
  foreign "WsMatchPolicyAlternative"
    ((ptr intptr_t) @-> uint32_t @-> (ptr void) @-> int32_t @-> (ptr intptr_t) @-> (ptr intptr_t) @-> returning int32_t)
(* policy : WS_POLICY* -> (ptr intptr_t) *)
(* alternativeIndex : DWORD -> uint32_t *)
(* policyConstraints : WS_POLICY_CONSTRAINTS* -> (ptr void) *)
(* matchRequired : BOOL -> int32_t *)
(* heap : WS_HEAP* -> (ptr intptr_t) *)
(* error : WS_ERROR* optional -> (ptr intptr_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library webservices (t "webservices.dll"))
(cffi:use-foreign-library webservices)

(cffi:defcfun ("WsMatchPolicyAlternative" ws-match-policy-alternative :convention :stdcall) :int32
  (policy :pointer)   ; WS_POLICY*
  (alternative-index :uint32)   ; DWORD
  (policy-constraints :pointer)   ; WS_POLICY_CONSTRAINTS*
  (match-required :int32)   ; BOOL
  (heap :pointer)   ; WS_HEAP*
  (error :pointer))   ; WS_ERROR* optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $WsMatchPolicyAlternative = Win32::API::More->new('webservices',
    'int WsMatchPolicyAlternative(LPVOID policy, DWORD alternativeIndex, LPVOID policyConstraints, BOOL matchRequired, LPVOID heap, LPVOID error)');
# my $ret = $WsMatchPolicyAlternative->Call($policy, $alternativeIndex, $policyConstraints, $matchRequired, $heap, $error);
# policy : WS_POLICY* -> LPVOID
# alternativeIndex : DWORD -> DWORD
# policyConstraints : WS_POLICY_CONSTRAINTS* -> LPVOID
# matchRequired : BOOL -> BOOL
# heap : WS_HEAP* -> LPVOID
# error : WS_ERROR* optional -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型