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
alternativeIndexDWORDin
policyConstraintsWS_POLICY_CONSTRAINTS*in
matchRequiredBOOLin
heapWS_HEAP*in
errorWS_ERROR*inoptional

戻り値の型: 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 policy, alternativeIndex, varptr(policyConstraints), matchRequired, heap, 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" int, int, var, int, int, int
; res = WsMatchPolicyAlternative(policy, alternativeIndex, policyConstraints, matchRequired, heap, error)
; policy : WS_POLICY* -> "int"
; alternativeIndex : DWORD -> "int"
; policyConstraints : WS_POLICY_CONSTRAINTS* -> "var"
; matchRequired : BOOL -> "int"
; heap : WS_HEAP* -> "int"
; error : WS_ERROR* optional -> "int"
; ※出力/バッファ引数は 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" int, int, var, int, int, int
; res = WsMatchPolicyAlternative(policy, alternativeIndex, policyConstraints, matchRequired, heap, error)
; policy : WS_POLICY* -> "int"
; alternativeIndex : DWORD -> "int"
; policyConstraints : WS_POLICY_CONSTRAINTS* -> "var"
; matchRequired : BOOL -> "int"
; heap : WS_HEAP* -> "int"
; error : WS_ERROR* optional -> "int"
; ※出力/バッファ引数は 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)。