Win32 API 日本語リファレンス
ホームSystem.Rpc › RpcServerInterfaceGroupCreateW

RpcServerInterfaceGroupCreateW

関数
複数のインターフェイスとエンドポイントをまとめたインターフェイスグループを作成する(Unicode版)。
DLLRPCRT4.dll文字セットUnicode (-W)呼出規約winapi対応OSwindows8.0

シグネチャ

// RPCRT4.dll  (Unicode / -W)
#include <windows.h>

RPC_STATUS RpcServerInterfaceGroupCreateW(
    RPC_INTERFACE_TEMPLATEW* Interfaces,
    DWORD NumIfs,
    RPC_ENDPOINT_TEMPLATEW* Endpoints,
    DWORD NumEndpoints,
    DWORD IdlePeriod,
    RPC_INTERFACE_GROUP_IDLE_CALLBACK_FN IdleCallbackFn,
    void* IdleCallbackContext,
    void** IfGroup
);

パラメーター

名前方向説明
InterfacesRPC_INTERFACE_TEMPLATEW*inグループへ登録するインターフェイステンプレート配列(Unicode)へのポインタ。
NumIfsDWORDinInterfaces配列に含まれるインターフェイスの数。
EndpointsRPC_ENDPOINT_TEMPLATEW*in使用するエンドポイントテンプレート配列(Unicode)へのポインタ。
NumEndpointsDWORDinEndpoints配列に含まれるエンドポイントの数。
IdlePeriodDWORDinアイドルコールバックを呼ぶまでの待機時間(ミリ秒)。
IdleCallbackFnRPC_INTERFACE_GROUP_IDLE_CALLBACK_FNinアイドル状態到達時に呼ばれるコールバック関数へのポインタ。NULL可。
IdleCallbackContextvoid*inIdleCallbackFnへ渡される任意のコンテキスト。NULL可。
IfGroupvoid**out作成されたインターフェイスグループのハンドルを受け取る出力先。

戻り値の型: RPC_STATUS

各言語での呼び出し定義

// RPCRT4.dll  (Unicode / -W)
#include <windows.h>

RPC_STATUS RpcServerInterfaceGroupCreateW(
    RPC_INTERFACE_TEMPLATEW* Interfaces,
    DWORD NumIfs,
    RPC_ENDPOINT_TEMPLATEW* Endpoints,
    DWORD NumEndpoints,
    DWORD IdlePeriod,
    RPC_INTERFACE_GROUP_IDLE_CALLBACK_FN IdleCallbackFn,
    void* IdleCallbackContext,
    void** IfGroup
);
[DllImport("RPCRT4.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern int RpcServerInterfaceGroupCreateW(
    IntPtr Interfaces,   // RPC_INTERFACE_TEMPLATEW*
    uint NumIfs,   // DWORD
    IntPtr Endpoints,   // RPC_ENDPOINT_TEMPLATEW*
    uint NumEndpoints,   // DWORD
    uint IdlePeriod,   // DWORD
    IntPtr IdleCallbackFn,   // RPC_INTERFACE_GROUP_IDLE_CALLBACK_FN
    IntPtr IdleCallbackContext,   // void*
    IntPtr IfGroup   // void** out
);
<DllImport("RPCRT4.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function RpcServerInterfaceGroupCreateW(
    Interfaces As IntPtr,   ' RPC_INTERFACE_TEMPLATEW*
    NumIfs As UInteger,   ' DWORD
    Endpoints As IntPtr,   ' RPC_ENDPOINT_TEMPLATEW*
    NumEndpoints As UInteger,   ' DWORD
    IdlePeriod As UInteger,   ' DWORD
    IdleCallbackFn As IntPtr,   ' RPC_INTERFACE_GROUP_IDLE_CALLBACK_FN
    IdleCallbackContext As IntPtr,   ' void*
    IfGroup As IntPtr   ' void** out
) As Integer
End Function
' Interfaces : RPC_INTERFACE_TEMPLATEW*
' NumIfs : DWORD
' Endpoints : RPC_ENDPOINT_TEMPLATEW*
' NumEndpoints : DWORD
' IdlePeriod : DWORD
' IdleCallbackFn : RPC_INTERFACE_GROUP_IDLE_CALLBACK_FN
' IdleCallbackContext : void*
' IfGroup : void** out
Declare PtrSafe Function RpcServerInterfaceGroupCreateW Lib "rpcrt4" ( _
    ByVal Interfaces As LongPtr, _
    ByVal NumIfs As Long, _
    ByVal Endpoints As LongPtr, _
    ByVal NumEndpoints As Long, _
    ByVal IdlePeriod As Long, _
    ByVal IdleCallbackFn As LongPtr, _
    ByVal IdleCallbackContext As LongPtr, _
    ByVal IfGroup As LongPtr) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

RpcServerInterfaceGroupCreateW = ctypes.windll.rpcrt4.RpcServerInterfaceGroupCreateW
RpcServerInterfaceGroupCreateW.restype = ctypes.c_int
RpcServerInterfaceGroupCreateW.argtypes = [
    ctypes.c_void_p,  # Interfaces : RPC_INTERFACE_TEMPLATEW*
    wintypes.DWORD,  # NumIfs : DWORD
    ctypes.c_void_p,  # Endpoints : RPC_ENDPOINT_TEMPLATEW*
    wintypes.DWORD,  # NumEndpoints : DWORD
    wintypes.DWORD,  # IdlePeriod : DWORD
    ctypes.c_void_p,  # IdleCallbackFn : RPC_INTERFACE_GROUP_IDLE_CALLBACK_FN
    ctypes.POINTER(None),  # IdleCallbackContext : void*
    ctypes.c_void_p,  # IfGroup : void** out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('RPCRT4.dll')
RpcServerInterfaceGroupCreateW = Fiddle::Function.new(
  lib['RpcServerInterfaceGroupCreateW'],
  [
    Fiddle::TYPE_VOIDP,  # Interfaces : RPC_INTERFACE_TEMPLATEW*
    -Fiddle::TYPE_INT,  # NumIfs : DWORD
    Fiddle::TYPE_VOIDP,  # Endpoints : RPC_ENDPOINT_TEMPLATEW*
    -Fiddle::TYPE_INT,  # NumEndpoints : DWORD
    -Fiddle::TYPE_INT,  # IdlePeriod : DWORD
    Fiddle::TYPE_VOIDP,  # IdleCallbackFn : RPC_INTERFACE_GROUP_IDLE_CALLBACK_FN
    Fiddle::TYPE_VOIDP,  # IdleCallbackContext : void*
    Fiddle::TYPE_VOIDP,  # IfGroup : void** out
  ],
  Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "rpcrt4")]
extern "system" {
    fn RpcServerInterfaceGroupCreateW(
        Interfaces: *mut RPC_INTERFACE_TEMPLATEW,  // RPC_INTERFACE_TEMPLATEW*
        NumIfs: u32,  // DWORD
        Endpoints: *mut RPC_ENDPOINT_TEMPLATEW,  // RPC_ENDPOINT_TEMPLATEW*
        NumEndpoints: u32,  // DWORD
        IdlePeriod: u32,  // DWORD
        IdleCallbackFn: *const core::ffi::c_void,  // RPC_INTERFACE_GROUP_IDLE_CALLBACK_FN
        IdleCallbackContext: *mut (),  // void*
        IfGroup: *mut *mut ()  // void** out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("RPCRT4.dll", CharSet = CharSet.Unicode)]
public static extern int RpcServerInterfaceGroupCreateW(IntPtr Interfaces, uint NumIfs, IntPtr Endpoints, uint NumEndpoints, uint IdlePeriod, IntPtr IdleCallbackFn, IntPtr IdleCallbackContext, IntPtr IfGroup);
"@
$api = Add-Type -MemberDefinition $sig -Name 'RPCRT4_RpcServerInterfaceGroupCreateW' -Namespace Win32 -PassThru
# $api::RpcServerInterfaceGroupCreateW(Interfaces, NumIfs, Endpoints, NumEndpoints, IdlePeriod, IdleCallbackFn, IdleCallbackContext, IfGroup)
#uselib "RPCRT4.dll"
#func global RpcServerInterfaceGroupCreateW "RpcServerInterfaceGroupCreateW" wptr, wptr, wptr, wptr, wptr, wptr, wptr, wptr
; RpcServerInterfaceGroupCreateW varptr(Interfaces), NumIfs, varptr(Endpoints), NumEndpoints, IdlePeriod, IdleCallbackFn, IdleCallbackContext, IfGroup   ; 戻り値は stat
; Interfaces : RPC_INTERFACE_TEMPLATEW* -> "wptr"
; NumIfs : DWORD -> "wptr"
; Endpoints : RPC_ENDPOINT_TEMPLATEW* -> "wptr"
; NumEndpoints : DWORD -> "wptr"
; IdlePeriod : DWORD -> "wptr"
; IdleCallbackFn : RPC_INTERFACE_GROUP_IDLE_CALLBACK_FN -> "wptr"
; IdleCallbackContext : void* -> "wptr"
; IfGroup : void** out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "RPCRT4.dll"
#cfunc global RpcServerInterfaceGroupCreateW "RpcServerInterfaceGroupCreateW" var, int, var, int, int, sptr, sptr, sptr
; res = RpcServerInterfaceGroupCreateW(Interfaces, NumIfs, Endpoints, NumEndpoints, IdlePeriod, IdleCallbackFn, IdleCallbackContext, IfGroup)
; Interfaces : RPC_INTERFACE_TEMPLATEW* -> "var"
; NumIfs : DWORD -> "int"
; Endpoints : RPC_ENDPOINT_TEMPLATEW* -> "var"
; NumEndpoints : DWORD -> "int"
; IdlePeriod : DWORD -> "int"
; IdleCallbackFn : RPC_INTERFACE_GROUP_IDLE_CALLBACK_FN -> "sptr"
; IdleCallbackContext : void* -> "sptr"
; IfGroup : void** out -> "sptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; RPC_STATUS RpcServerInterfaceGroupCreateW(RPC_INTERFACE_TEMPLATEW* Interfaces, DWORD NumIfs, RPC_ENDPOINT_TEMPLATEW* Endpoints, DWORD NumEndpoints, DWORD IdlePeriod, RPC_INTERFACE_GROUP_IDLE_CALLBACK_FN IdleCallbackFn, void* IdleCallbackContext, void** IfGroup)
#uselib "RPCRT4.dll"
#cfunc global RpcServerInterfaceGroupCreateW "RpcServerInterfaceGroupCreateW" var, int, var, int, int, intptr, intptr, intptr
; res = RpcServerInterfaceGroupCreateW(Interfaces, NumIfs, Endpoints, NumEndpoints, IdlePeriod, IdleCallbackFn, IdleCallbackContext, IfGroup)
; Interfaces : RPC_INTERFACE_TEMPLATEW* -> "var"
; NumIfs : DWORD -> "int"
; Endpoints : RPC_ENDPOINT_TEMPLATEW* -> "var"
; NumEndpoints : DWORD -> "int"
; IdlePeriod : DWORD -> "int"
; IdleCallbackFn : RPC_INTERFACE_GROUP_IDLE_CALLBACK_FN -> "intptr"
; IdleCallbackContext : void* -> "intptr"
; IfGroup : void** out -> "intptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	rpcrt4 = windows.NewLazySystemDLL("RPCRT4.dll")
	procRpcServerInterfaceGroupCreateW = rpcrt4.NewProc("RpcServerInterfaceGroupCreateW")
)

// Interfaces (RPC_INTERFACE_TEMPLATEW*), NumIfs (DWORD), Endpoints (RPC_ENDPOINT_TEMPLATEW*), NumEndpoints (DWORD), IdlePeriod (DWORD), IdleCallbackFn (RPC_INTERFACE_GROUP_IDLE_CALLBACK_FN), IdleCallbackContext (void*), IfGroup (void** out)
r1, _, err := procRpcServerInterfaceGroupCreateW.Call(
	uintptr(Interfaces),
	uintptr(NumIfs),
	uintptr(Endpoints),
	uintptr(NumEndpoints),
	uintptr(IdlePeriod),
	uintptr(IdleCallbackFn),
	uintptr(IdleCallbackContext),
	uintptr(IfGroup),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // RPC_STATUS
function RpcServerInterfaceGroupCreateW(
  Interfaces: Pointer;   // RPC_INTERFACE_TEMPLATEW*
  NumIfs: DWORD;   // DWORD
  Endpoints: Pointer;   // RPC_ENDPOINT_TEMPLATEW*
  NumEndpoints: DWORD;   // DWORD
  IdlePeriod: DWORD;   // DWORD
  IdleCallbackFn: Pointer;   // RPC_INTERFACE_GROUP_IDLE_CALLBACK_FN
  IdleCallbackContext: Pointer;   // void*
  IfGroup: Pointer   // void** out
): Integer; stdcall;
  external 'RPCRT4.dll' name 'RpcServerInterfaceGroupCreateW';
result := DllCall("RPCRT4\RpcServerInterfaceGroupCreateW"
    , "Ptr", Interfaces   ; RPC_INTERFACE_TEMPLATEW*
    , "UInt", NumIfs   ; DWORD
    , "Ptr", Endpoints   ; RPC_ENDPOINT_TEMPLATEW*
    , "UInt", NumEndpoints   ; DWORD
    , "UInt", IdlePeriod   ; DWORD
    , "Ptr", IdleCallbackFn   ; RPC_INTERFACE_GROUP_IDLE_CALLBACK_FN
    , "Ptr", IdleCallbackContext   ; void*
    , "Ptr", IfGroup   ; void** out
    , "Int")   ; return: RPC_STATUS
●RpcServerInterfaceGroupCreateW(Interfaces, NumIfs, Endpoints, NumEndpoints, IdlePeriod, IdleCallbackFn, IdleCallbackContext, IfGroup) = DLL("RPCRT4.dll", "int RpcServerInterfaceGroupCreateW(void*, dword, void*, dword, dword, void*, void*, void*)")
# 呼び出し: RpcServerInterfaceGroupCreateW(Interfaces, NumIfs, Endpoints, NumEndpoints, IdlePeriod, IdleCallbackFn, IdleCallbackContext, IfGroup)
# Interfaces : RPC_INTERFACE_TEMPLATEW* -> "void*"
# NumIfs : DWORD -> "dword"
# Endpoints : RPC_ENDPOINT_TEMPLATEW* -> "void*"
# NumEndpoints : DWORD -> "dword"
# IdlePeriod : DWORD -> "dword"
# IdleCallbackFn : RPC_INTERFACE_GROUP_IDLE_CALLBACK_FN -> "void*"
# IdleCallbackContext : void* -> "void*"
# IfGroup : void** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。
const std = @import("std");

extern "rpcrt4" fn RpcServerInterfaceGroupCreateW(
    Interfaces: [*c]RPC_INTERFACE_TEMPLATEW, // RPC_INTERFACE_TEMPLATEW*
    NumIfs: u32, // DWORD
    Endpoints: [*c]RPC_ENDPOINT_TEMPLATEW, // RPC_ENDPOINT_TEMPLATEW*
    NumEndpoints: u32, // DWORD
    IdlePeriod: u32, // DWORD
    IdleCallbackFn: ?*anyopaque, // RPC_INTERFACE_GROUP_IDLE_CALLBACK_FN
    IdleCallbackContext: ?*anyopaque, // void*
    IfGroup: ?*anyopaque // void** out
) callconv(std.os.windows.WINAPI) i32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。
proc RpcServerInterfaceGroupCreateW(
    Interfaces: ptr RPC_INTERFACE_TEMPLATEW,  # RPC_INTERFACE_TEMPLATEW*
    NumIfs: uint32,  # DWORD
    Endpoints: ptr RPC_ENDPOINT_TEMPLATEW,  # RPC_ENDPOINT_TEMPLATEW*
    NumEndpoints: uint32,  # DWORD
    IdlePeriod: uint32,  # DWORD
    IdleCallbackFn: pointer,  # RPC_INTERFACE_GROUP_IDLE_CALLBACK_FN
    IdleCallbackContext: pointer,  # void*
    IfGroup: pointer  # void** out
): int32 {.importc: "RpcServerInterfaceGroupCreateW", stdcall, dynlib: "RPCRT4.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。
pragma(lib, "rpcrt4");
extern(Windows)
int RpcServerInterfaceGroupCreateW(
    RPC_INTERFACE_TEMPLATEW* Interfaces,   // RPC_INTERFACE_TEMPLATEW*
    uint NumIfs,   // DWORD
    RPC_ENDPOINT_TEMPLATEW* Endpoints,   // RPC_ENDPOINT_TEMPLATEW*
    uint NumEndpoints,   // DWORD
    uint IdlePeriod,   // DWORD
    void* IdleCallbackFn,   // RPC_INTERFACE_GROUP_IDLE_CALLBACK_FN
    void* IdleCallbackContext,   // void*
    void** IfGroup   // void** out
);
ccall((:RpcServerInterfaceGroupCreateW, "RPCRT4.dll"), stdcall, Int32,
      (Ptr{RPC_INTERFACE_TEMPLATEW}, UInt32, Ptr{RPC_ENDPOINT_TEMPLATEW}, UInt32, UInt32, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}),
      Interfaces, NumIfs, Endpoints, NumEndpoints, IdlePeriod, IdleCallbackFn, IdleCallbackContext, IfGroup)
# Interfaces : RPC_INTERFACE_TEMPLATEW* -> Ptr{RPC_INTERFACE_TEMPLATEW}
# NumIfs : DWORD -> UInt32
# Endpoints : RPC_ENDPOINT_TEMPLATEW* -> Ptr{RPC_ENDPOINT_TEMPLATEW}
# NumEndpoints : DWORD -> UInt32
# IdlePeriod : DWORD -> UInt32
# IdleCallbackFn : RPC_INTERFACE_GROUP_IDLE_CALLBACK_FN -> Ptr{Cvoid}
# IdleCallbackContext : void* -> Ptr{Cvoid}
# IfGroup : void** out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。
local ffi = require("ffi")
ffi.cdef[[
int32_t RpcServerInterfaceGroupCreateW(
    void* Interfaces,
    uint32_t NumIfs,
    void* Endpoints,
    uint32_t NumEndpoints,
    uint32_t IdlePeriod,
    void* IdleCallbackFn,
    void* IdleCallbackContext,
    void** IfGroup);
]]
local rpcrt4 = ffi.load("rpcrt4")
-- rpcrt4.RpcServerInterfaceGroupCreateW(Interfaces, NumIfs, Endpoints, NumEndpoints, IdlePeriod, IdleCallbackFn, IdleCallbackContext, IfGroup)
-- Interfaces : RPC_INTERFACE_TEMPLATEW*
-- NumIfs : DWORD
-- Endpoints : RPC_ENDPOINT_TEMPLATEW*
-- NumEndpoints : DWORD
-- IdlePeriod : DWORD
-- IdleCallbackFn : RPC_INTERFACE_GROUP_IDLE_CALLBACK_FN
-- IdleCallbackContext : void*
-- IfGroup : void** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。
const koffi = require('koffi');
const lib = koffi.load('RPCRT4.dll');
const RpcServerInterfaceGroupCreateW = lib.func('__stdcall', 'RpcServerInterfaceGroupCreateW', 'int32_t', ['void *', 'uint32_t', 'void *', 'uint32_t', 'uint32_t', 'void *', 'void *', 'void *']);
// RpcServerInterfaceGroupCreateW(Interfaces, NumIfs, Endpoints, NumEndpoints, IdlePeriod, IdleCallbackFn, IdleCallbackContext, IfGroup)
// Interfaces : RPC_INTERFACE_TEMPLATEW* -> 'void *'
// NumIfs : DWORD -> 'uint32_t'
// Endpoints : RPC_ENDPOINT_TEMPLATEW* -> 'void *'
// NumEndpoints : DWORD -> 'uint32_t'
// IdlePeriod : DWORD -> 'uint32_t'
// IdleCallbackFn : RPC_INTERFACE_GROUP_IDLE_CALLBACK_FN -> 'void *'
// IdleCallbackContext : void* -> 'void *'
// IfGroup : void** out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
// コールバック(関数ポインタ)は koffi.proto/koffi.register で型を定義して渡す(素の void* では JS 関数を渡せない)。
const lib = Deno.dlopen("RPCRT4.dll", {
  RpcServerInterfaceGroupCreateW: { parameters: ["pointer", "u32", "pointer", "u32", "u32", "pointer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.RpcServerInterfaceGroupCreateW(Interfaces, NumIfs, Endpoints, NumEndpoints, IdlePeriod, IdleCallbackFn, IdleCallbackContext, IfGroup)
// Interfaces : RPC_INTERFACE_TEMPLATEW* -> "pointer"
// NumIfs : DWORD -> "u32"
// Endpoints : RPC_ENDPOINT_TEMPLATEW* -> "pointer"
// NumEndpoints : DWORD -> "u32"
// IdlePeriod : DWORD -> "u32"
// IdleCallbackFn : RPC_INTERFACE_GROUP_IDLE_CALLBACK_FN -> "pointer"
// IdleCallbackContext : void* -> "pointer"
// IfGroup : void** out -> "pointer"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t RpcServerInterfaceGroupCreateW(
    void* Interfaces,
    uint32_t NumIfs,
    void* Endpoints,
    uint32_t NumEndpoints,
    uint32_t IdlePeriod,
    void* IdleCallbackFn,
    void* IdleCallbackContext,
    void** IfGroup);
C, "RPCRT4.dll");
// $ffi->RpcServerInterfaceGroupCreateW(Interfaces, NumIfs, Endpoints, NumEndpoints, IdlePeriod, IdleCallbackFn, IdleCallbackContext, IfGroup);
// Interfaces : RPC_INTERFACE_TEMPLATEW*
// NumIfs : DWORD
// Endpoints : RPC_ENDPOINT_TEMPLATEW*
// NumEndpoints : DWORD
// IdlePeriod : DWORD
// IdleCallbackFn : RPC_INTERFACE_GROUP_IDLE_CALLBACK_FN
// IdleCallbackContext : void*
// IfGroup : void** 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 Rpcrt4 extends StdCallLibrary {
    Rpcrt4 INSTANCE = Native.load("rpcrt4", Rpcrt4.class, W32APIOptions.UNICODE_OPTIONS);
    int RpcServerInterfaceGroupCreateW(
        Pointer Interfaces,   // RPC_INTERFACE_TEMPLATEW*
        int NumIfs,   // DWORD
        Pointer Endpoints,   // RPC_ENDPOINT_TEMPLATEW*
        int NumEndpoints,   // DWORD
        int IdlePeriod,   // DWORD
        Callback IdleCallbackFn,   // RPC_INTERFACE_GROUP_IDLE_CALLBACK_FN
        Pointer IdleCallbackContext,   // void*
        Pointer IfGroup   // void** out
    );
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。
@[Link("rpcrt4")]
lib LibRPCRT4
  fun RpcServerInterfaceGroupCreateW = RpcServerInterfaceGroupCreateW(
    Interfaces : RPC_INTERFACE_TEMPLATEW*,   # RPC_INTERFACE_TEMPLATEW*
    NumIfs : UInt32,   # DWORD
    Endpoints : RPC_ENDPOINT_TEMPLATEW*,   # RPC_ENDPOINT_TEMPLATEW*
    NumEndpoints : UInt32,   # DWORD
    IdlePeriod : UInt32,   # DWORD
    IdleCallbackFn : Void*,   # RPC_INTERFACE_GROUP_IDLE_CALLBACK_FN
    IdleCallbackContext : Void*,   # void*
    IfGroup : Void**   # void** out
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef RpcServerInterfaceGroupCreateWNative = Int32 Function(Pointer<Void>, Uint32, Pointer<Void>, Uint32, Uint32, Pointer<Void>, Pointer<Void>, Pointer<Void>);
typedef RpcServerInterfaceGroupCreateWDart = int Function(Pointer<Void>, int, Pointer<Void>, int, int, Pointer<Void>, Pointer<Void>, Pointer<Void>);
final RpcServerInterfaceGroupCreateW = DynamicLibrary.open('RPCRT4.dll')
    .lookupFunction<RpcServerInterfaceGroupCreateWNative, RpcServerInterfaceGroupCreateWDart>('RpcServerInterfaceGroupCreateW');
// Interfaces : RPC_INTERFACE_TEMPLATEW* -> Pointer<Void>
// NumIfs : DWORD -> Uint32
// Endpoints : RPC_ENDPOINT_TEMPLATEW* -> Pointer<Void>
// NumEndpoints : DWORD -> Uint32
// IdlePeriod : DWORD -> Uint32
// IdleCallbackFn : RPC_INTERFACE_GROUP_IDLE_CALLBACK_FN -> Pointer<Void>
// IdleCallbackContext : void* -> Pointer<Void>
// IfGroup : void** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function RpcServerInterfaceGroupCreateW(
  Interfaces: Pointer;   // RPC_INTERFACE_TEMPLATEW*
  NumIfs: DWORD;   // DWORD
  Endpoints: Pointer;   // RPC_ENDPOINT_TEMPLATEW*
  NumEndpoints: DWORD;   // DWORD
  IdlePeriod: DWORD;   // DWORD
  IdleCallbackFn: Pointer;   // RPC_INTERFACE_GROUP_IDLE_CALLBACK_FN
  IdleCallbackContext: Pointer;   // void*
  IfGroup: Pointer   // void** out
): Integer; stdcall;
  external 'RPCRT4.dll' name 'RpcServerInterfaceGroupCreateW';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "RpcServerInterfaceGroupCreateW"
  c_RpcServerInterfaceGroupCreateW :: Ptr () -> Word32 -> Ptr () -> Word32 -> Word32 -> Ptr () -> Ptr () -> Ptr () -> IO Int32
-- Interfaces : RPC_INTERFACE_TEMPLATEW* -> Ptr ()
-- NumIfs : DWORD -> Word32
-- Endpoints : RPC_ENDPOINT_TEMPLATEW* -> Ptr ()
-- NumEndpoints : DWORD -> Word32
-- IdlePeriod : DWORD -> Word32
-- IdleCallbackFn : RPC_INTERFACE_GROUP_IDLE_CALLBACK_FN -> Ptr ()
-- IdleCallbackContext : void* -> Ptr ()
-- IfGroup : void** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let rpcserverinterfacegroupcreatew =
  foreign "RpcServerInterfaceGroupCreateW"
    ((ptr void) @-> uint32_t @-> (ptr void) @-> uint32_t @-> uint32_t @-> (ptr void) @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* Interfaces : RPC_INTERFACE_TEMPLATEW* -> (ptr void) *)
(* NumIfs : DWORD -> uint32_t *)
(* Endpoints : RPC_ENDPOINT_TEMPLATEW* -> (ptr void) *)
(* NumEndpoints : DWORD -> uint32_t *)
(* IdlePeriod : DWORD -> uint32_t *)
(* IdleCallbackFn : RPC_INTERFACE_GROUP_IDLE_CALLBACK_FN -> (ptr void) *)
(* IdleCallbackContext : void* -> (ptr void) *)
(* IfGroup : void** out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library rpcrt4 (t "RPCRT4.dll"))
(cffi:use-foreign-library rpcrt4)

(cffi:defcfun ("RpcServerInterfaceGroupCreateW" rpc-server-interface-group-create-w :convention :stdcall) :int32
  (interfaces :pointer)   ; RPC_INTERFACE_TEMPLATEW*
  (num-ifs :uint32)   ; DWORD
  (endpoints :pointer)   ; RPC_ENDPOINT_TEMPLATEW*
  (num-endpoints :uint32)   ; DWORD
  (idle-period :uint32)   ; DWORD
  (idle-callback-fn :pointer)   ; RPC_INTERFACE_GROUP_IDLE_CALLBACK_FN
  (idle-callback-context :pointer)   ; void*
  (if-group :pointer))   ; void** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $RpcServerInterfaceGroupCreateW = Win32::API::More->new('RPCRT4',
    'int RpcServerInterfaceGroupCreateW(LPVOID Interfaces, DWORD NumIfs, LPVOID Endpoints, DWORD NumEndpoints, DWORD IdlePeriod, LPVOID IdleCallbackFn, LPVOID IdleCallbackContext, LPVOID IfGroup)');
# my $ret = $RpcServerInterfaceGroupCreateW->Call($Interfaces, $NumIfs, $Endpoints, $NumEndpoints, $IdlePeriod, $IdleCallbackFn, $IdleCallbackContext, $IfGroup);
# Interfaces : RPC_INTERFACE_TEMPLATEW* -> LPVOID
# NumIfs : DWORD -> DWORD
# Endpoints : RPC_ENDPOINT_TEMPLATEW* -> LPVOID
# NumEndpoints : DWORD -> DWORD
# IdlePeriod : DWORD -> DWORD
# IdleCallbackFn : RPC_INTERFACE_GROUP_IDLE_CALLBACK_FN -> LPVOID
# IdleCallbackContext : void* -> LPVOID
# IfGroup : void** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# コールバック(関数ポインタ)は Perl sub を直接渡せません。Win32::API::Callback を使用してください。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。

関連項目

文字セット違い
使用する型