Win32 API 日本語リファレンス
ホームNetworkManagement.WindowsConnectionManager › GetInterfaceContextTableForHostName

GetInterfaceContextTableForHostName

関数
指定ホスト名に対応するインターフェイスコンテキストテーブルを取得する。
DLLOnDemandConnRouteHelper.dll呼出規約winapi対応OSWindows 10 以降

シグネチャ

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

HRESULT GetInterfaceContextTableForHostName(
    LPCWSTR HostName,   // optional
    LPCWSTR ProxyName,   // optional
    DWORD Flags,
    BYTE* ConnectionProfileFilterRawData,   // optional
    DWORD ConnectionProfileFilterRawDataSize,
    NET_INTERFACE_CONTEXT_TABLE** InterfaceContextTable
);

パラメーター

名前方向説明
HostNameLPCWSTRinoptionalコンテキストテーブルを取得する対象の接続先ホスト名を指す文字列。
ProxyNameLPCWSTRinoptional使用するプロキシ名を指す文字列。NULL可。
FlagsDWORDinコンテキストテーブル生成の動作を制御するフラグ。
ConnectionProfileFilterRawDataBYTE*inoptional接続プロファイルをフィルターする生データへのポインター。NULL可。
ConnectionProfileFilterRawDataSizeDWORDinConnectionProfileFilterRawDataのバイト数。
InterfaceContextTableNET_INTERFACE_CONTEXT_TABLE**out生成されたインターフェースコンテキストテーブルを受け取るポインター。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT GetInterfaceContextTableForHostName(
    LPCWSTR HostName,   // optional
    LPCWSTR ProxyName,   // optional
    DWORD Flags,
    BYTE* ConnectionProfileFilterRawData,   // optional
    DWORD ConnectionProfileFilterRawDataSize,
    NET_INTERFACE_CONTEXT_TABLE** InterfaceContextTable
);
[DllImport("OnDemandConnRouteHelper.dll", ExactSpelling = true)]
static extern int GetInterfaceContextTableForHostName(
    [MarshalAs(UnmanagedType.LPWStr)] string HostName,   // LPCWSTR optional
    [MarshalAs(UnmanagedType.LPWStr)] string ProxyName,   // LPCWSTR optional
    uint Flags,   // DWORD
    IntPtr ConnectionProfileFilterRawData,   // BYTE* optional
    uint ConnectionProfileFilterRawDataSize,   // DWORD
    IntPtr InterfaceContextTable   // NET_INTERFACE_CONTEXT_TABLE** out
);
<DllImport("OnDemandConnRouteHelper.dll", ExactSpelling:=True)>
Public Shared Function GetInterfaceContextTableForHostName(
    <MarshalAs(UnmanagedType.LPWStr)> HostName As String,   ' LPCWSTR optional
    <MarshalAs(UnmanagedType.LPWStr)> ProxyName As String,   ' LPCWSTR optional
    Flags As UInteger,   ' DWORD
    ConnectionProfileFilterRawData As IntPtr,   ' BYTE* optional
    ConnectionProfileFilterRawDataSize As UInteger,   ' DWORD
    InterfaceContextTable As IntPtr   ' NET_INTERFACE_CONTEXT_TABLE** out
) As Integer
End Function
' HostName : LPCWSTR optional
' ProxyName : LPCWSTR optional
' Flags : DWORD
' ConnectionProfileFilterRawData : BYTE* optional
' ConnectionProfileFilterRawDataSize : DWORD
' InterfaceContextTable : NET_INTERFACE_CONTEXT_TABLE** out
Declare PtrSafe Function GetInterfaceContextTableForHostName Lib "ondemandconnroutehelper" ( _
    ByVal HostName As LongPtr, _
    ByVal ProxyName As LongPtr, _
    ByVal Flags As Long, _
    ByVal ConnectionProfileFilterRawData As LongPtr, _
    ByVal ConnectionProfileFilterRawDataSize As Long, _
    ByVal InterfaceContextTable As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GetInterfaceContextTableForHostName = ctypes.windll.ondemandconnroutehelper.GetInterfaceContextTableForHostName
GetInterfaceContextTableForHostName.restype = ctypes.c_int
GetInterfaceContextTableForHostName.argtypes = [
    wintypes.LPCWSTR,  # HostName : LPCWSTR optional
    wintypes.LPCWSTR,  # ProxyName : LPCWSTR optional
    wintypes.DWORD,  # Flags : DWORD
    ctypes.POINTER(ctypes.c_ubyte),  # ConnectionProfileFilterRawData : BYTE* optional
    wintypes.DWORD,  # ConnectionProfileFilterRawDataSize : DWORD
    ctypes.c_void_p,  # InterfaceContextTable : NET_INTERFACE_CONTEXT_TABLE** out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('OnDemandConnRouteHelper.dll')
GetInterfaceContextTableForHostName = Fiddle::Function.new(
  lib['GetInterfaceContextTableForHostName'],
  [
    Fiddle::TYPE_VOIDP,  # HostName : LPCWSTR optional
    Fiddle::TYPE_VOIDP,  # ProxyName : LPCWSTR optional
    -Fiddle::TYPE_INT,  # Flags : DWORD
    Fiddle::TYPE_VOIDP,  # ConnectionProfileFilterRawData : BYTE* optional
    -Fiddle::TYPE_INT,  # ConnectionProfileFilterRawDataSize : DWORD
    Fiddle::TYPE_VOIDP,  # InterfaceContextTable : NET_INTERFACE_CONTEXT_TABLE** out
  ],
  Fiddle::TYPE_INT)
#[link(name = "ondemandconnroutehelper")]
extern "system" {
    fn GetInterfaceContextTableForHostName(
        HostName: *const u16,  // LPCWSTR optional
        ProxyName: *const u16,  // LPCWSTR optional
        Flags: u32,  // DWORD
        ConnectionProfileFilterRawData: *mut u8,  // BYTE* optional
        ConnectionProfileFilterRawDataSize: u32,  // DWORD
        InterfaceContextTable: *mut *mut NET_INTERFACE_CONTEXT_TABLE  // NET_INTERFACE_CONTEXT_TABLE** out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("OnDemandConnRouteHelper.dll")]
public static extern int GetInterfaceContextTableForHostName([MarshalAs(UnmanagedType.LPWStr)] string HostName, [MarshalAs(UnmanagedType.LPWStr)] string ProxyName, uint Flags, IntPtr ConnectionProfileFilterRawData, uint ConnectionProfileFilterRawDataSize, IntPtr InterfaceContextTable);
"@
$api = Add-Type -MemberDefinition $sig -Name 'OnDemandConnRouteHelper_GetInterfaceContextTableForHostName' -Namespace Win32 -PassThru
# $api::GetInterfaceContextTableForHostName(HostName, ProxyName, Flags, ConnectionProfileFilterRawData, ConnectionProfileFilterRawDataSize, InterfaceContextTable)
#uselib "OnDemandConnRouteHelper.dll"
#func global GetInterfaceContextTableForHostName "GetInterfaceContextTableForHostName" sptr, sptr, sptr, sptr, sptr, sptr
; GetInterfaceContextTableForHostName HostName, ProxyName, Flags, varptr(ConnectionProfileFilterRawData), ConnectionProfileFilterRawDataSize, varptr(InterfaceContextTable)   ; 戻り値は stat
; HostName : LPCWSTR optional -> "sptr"
; ProxyName : LPCWSTR optional -> "sptr"
; Flags : DWORD -> "sptr"
; ConnectionProfileFilterRawData : BYTE* optional -> "sptr"
; ConnectionProfileFilterRawDataSize : DWORD -> "sptr"
; InterfaceContextTable : NET_INTERFACE_CONTEXT_TABLE** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "OnDemandConnRouteHelper.dll"
#cfunc global GetInterfaceContextTableForHostName "GetInterfaceContextTableForHostName" wstr, wstr, int, var, int, var
; res = GetInterfaceContextTableForHostName(HostName, ProxyName, Flags, ConnectionProfileFilterRawData, ConnectionProfileFilterRawDataSize, InterfaceContextTable)
; HostName : LPCWSTR optional -> "wstr"
; ProxyName : LPCWSTR optional -> "wstr"
; Flags : DWORD -> "int"
; ConnectionProfileFilterRawData : BYTE* optional -> "var"
; ConnectionProfileFilterRawDataSize : DWORD -> "int"
; InterfaceContextTable : NET_INTERFACE_CONTEXT_TABLE** out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT GetInterfaceContextTableForHostName(LPCWSTR HostName, LPCWSTR ProxyName, DWORD Flags, BYTE* ConnectionProfileFilterRawData, DWORD ConnectionProfileFilterRawDataSize, NET_INTERFACE_CONTEXT_TABLE** InterfaceContextTable)
#uselib "OnDemandConnRouteHelper.dll"
#cfunc global GetInterfaceContextTableForHostName "GetInterfaceContextTableForHostName" wstr, wstr, int, var, int, var
; res = GetInterfaceContextTableForHostName(HostName, ProxyName, Flags, ConnectionProfileFilterRawData, ConnectionProfileFilterRawDataSize, InterfaceContextTable)
; HostName : LPCWSTR optional -> "wstr"
; ProxyName : LPCWSTR optional -> "wstr"
; Flags : DWORD -> "int"
; ConnectionProfileFilterRawData : BYTE* optional -> "var"
; ConnectionProfileFilterRawDataSize : DWORD -> "int"
; InterfaceContextTable : NET_INTERFACE_CONTEXT_TABLE** out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	ondemandconnroutehelper = windows.NewLazySystemDLL("OnDemandConnRouteHelper.dll")
	procGetInterfaceContextTableForHostName = ondemandconnroutehelper.NewProc("GetInterfaceContextTableForHostName")
)

// HostName (LPCWSTR optional), ProxyName (LPCWSTR optional), Flags (DWORD), ConnectionProfileFilterRawData (BYTE* optional), ConnectionProfileFilterRawDataSize (DWORD), InterfaceContextTable (NET_INTERFACE_CONTEXT_TABLE** out)
r1, _, err := procGetInterfaceContextTableForHostName.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(HostName))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(ProxyName))),
	uintptr(Flags),
	uintptr(ConnectionProfileFilterRawData),
	uintptr(ConnectionProfileFilterRawDataSize),
	uintptr(InterfaceContextTable),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function GetInterfaceContextTableForHostName(
  HostName: PWideChar;   // LPCWSTR optional
  ProxyName: PWideChar;   // LPCWSTR optional
  Flags: DWORD;   // DWORD
  ConnectionProfileFilterRawData: Pointer;   // BYTE* optional
  ConnectionProfileFilterRawDataSize: DWORD;   // DWORD
  InterfaceContextTable: Pointer   // NET_INTERFACE_CONTEXT_TABLE** out
): Integer; stdcall;
  external 'OnDemandConnRouteHelper.dll' name 'GetInterfaceContextTableForHostName';
result := DllCall("OnDemandConnRouteHelper\GetInterfaceContextTableForHostName"
    , "WStr", HostName   ; LPCWSTR optional
    , "WStr", ProxyName   ; LPCWSTR optional
    , "UInt", Flags   ; DWORD
    , "Ptr", ConnectionProfileFilterRawData   ; BYTE* optional
    , "UInt", ConnectionProfileFilterRawDataSize   ; DWORD
    , "Ptr", InterfaceContextTable   ; NET_INTERFACE_CONTEXT_TABLE** out
    , "Int")   ; return: HRESULT
●GetInterfaceContextTableForHostName(HostName, ProxyName, Flags, ConnectionProfileFilterRawData, ConnectionProfileFilterRawDataSize, InterfaceContextTable) = DLL("OnDemandConnRouteHelper.dll", "int GetInterfaceContextTableForHostName(char*, char*, dword, void*, dword, void*)")
# 呼び出し: GetInterfaceContextTableForHostName(HostName, ProxyName, Flags, ConnectionProfileFilterRawData, ConnectionProfileFilterRawDataSize, InterfaceContextTable)
# HostName : LPCWSTR optional -> "char*"
# ProxyName : LPCWSTR optional -> "char*"
# Flags : DWORD -> "dword"
# ConnectionProfileFilterRawData : BYTE* optional -> "void*"
# ConnectionProfileFilterRawDataSize : DWORD -> "dword"
# InterfaceContextTable : NET_INTERFACE_CONTEXT_TABLE** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "ondemandconnroutehelper" fn GetInterfaceContextTableForHostName(
    HostName: [*c]const u16, // LPCWSTR optional
    ProxyName: [*c]const u16, // LPCWSTR optional
    Flags: u32, // DWORD
    ConnectionProfileFilterRawData: [*c]u8, // BYTE* optional
    ConnectionProfileFilterRawDataSize: u32, // DWORD
    InterfaceContextTable: [*c][*c]NET_INTERFACE_CONTEXT_TABLE // NET_INTERFACE_CONTEXT_TABLE** out
) callconv(std.os.windows.WINAPI) i32;
proc GetInterfaceContextTableForHostName(
    HostName: WideCString,  # LPCWSTR optional
    ProxyName: WideCString,  # LPCWSTR optional
    Flags: uint32,  # DWORD
    ConnectionProfileFilterRawData: ptr uint8,  # BYTE* optional
    ConnectionProfileFilterRawDataSize: uint32,  # DWORD
    InterfaceContextTable: ptr NET_INTERFACE_CONTEXT_TABLE  # NET_INTERFACE_CONTEXT_TABLE** out
): int32 {.importc: "GetInterfaceContextTableForHostName", stdcall, dynlib: "OnDemandConnRouteHelper.dll".}
pragma(lib, "ondemandconnroutehelper");
extern(Windows)
int GetInterfaceContextTableForHostName(
    const(wchar)* HostName,   // LPCWSTR optional
    const(wchar)* ProxyName,   // LPCWSTR optional
    uint Flags,   // DWORD
    ubyte* ConnectionProfileFilterRawData,   // BYTE* optional
    uint ConnectionProfileFilterRawDataSize,   // DWORD
    NET_INTERFACE_CONTEXT_TABLE** InterfaceContextTable   // NET_INTERFACE_CONTEXT_TABLE** out
);
ccall((:GetInterfaceContextTableForHostName, "OnDemandConnRouteHelper.dll"), stdcall, Int32,
      (Cwstring, Cwstring, UInt32, Ptr{UInt8}, UInt32, Ptr{NET_INTERFACE_CONTEXT_TABLE}),
      HostName, ProxyName, Flags, ConnectionProfileFilterRawData, ConnectionProfileFilterRawDataSize, InterfaceContextTable)
# HostName : LPCWSTR optional -> Cwstring
# ProxyName : LPCWSTR optional -> Cwstring
# Flags : DWORD -> UInt32
# ConnectionProfileFilterRawData : BYTE* optional -> Ptr{UInt8}
# ConnectionProfileFilterRawDataSize : DWORD -> UInt32
# InterfaceContextTable : NET_INTERFACE_CONTEXT_TABLE** out -> Ptr{NET_INTERFACE_CONTEXT_TABLE}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t GetInterfaceContextTableForHostName(
    const uint16_t* HostName,
    const uint16_t* ProxyName,
    uint32_t Flags,
    uint8_t* ConnectionProfileFilterRawData,
    uint32_t ConnectionProfileFilterRawDataSize,
    void* InterfaceContextTable);
]]
local ondemandconnroutehelper = ffi.load("ondemandconnroutehelper")
-- ondemandconnroutehelper.GetInterfaceContextTableForHostName(HostName, ProxyName, Flags, ConnectionProfileFilterRawData, ConnectionProfileFilterRawDataSize, InterfaceContextTable)
-- HostName : LPCWSTR optional
-- ProxyName : LPCWSTR optional
-- Flags : DWORD
-- ConnectionProfileFilterRawData : BYTE* optional
-- ConnectionProfileFilterRawDataSize : DWORD
-- InterfaceContextTable : NET_INTERFACE_CONTEXT_TABLE** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('OnDemandConnRouteHelper.dll');
const GetInterfaceContextTableForHostName = lib.func('__stdcall', 'GetInterfaceContextTableForHostName', 'int32_t', ['str16', 'str16', 'uint32_t', 'uint8_t *', 'uint32_t', 'void *']);
// GetInterfaceContextTableForHostName(HostName, ProxyName, Flags, ConnectionProfileFilterRawData, ConnectionProfileFilterRawDataSize, InterfaceContextTable)
// HostName : LPCWSTR optional -> 'str16'
// ProxyName : LPCWSTR optional -> 'str16'
// Flags : DWORD -> 'uint32_t'
// ConnectionProfileFilterRawData : BYTE* optional -> 'uint8_t *'
// ConnectionProfileFilterRawDataSize : DWORD -> 'uint32_t'
// InterfaceContextTable : NET_INTERFACE_CONTEXT_TABLE** out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("OnDemandConnRouteHelper.dll", {
  GetInterfaceContextTableForHostName: { parameters: ["buffer", "buffer", "u32", "pointer", "u32", "pointer"], result: "i32" },
});
// lib.symbols.GetInterfaceContextTableForHostName(HostName, ProxyName, Flags, ConnectionProfileFilterRawData, ConnectionProfileFilterRawDataSize, InterfaceContextTable)
// HostName : LPCWSTR optional -> "buffer"
// ProxyName : LPCWSTR optional -> "buffer"
// Flags : DWORD -> "u32"
// ConnectionProfileFilterRawData : BYTE* optional -> "pointer"
// ConnectionProfileFilterRawDataSize : DWORD -> "u32"
// InterfaceContextTable : NET_INTERFACE_CONTEXT_TABLE** out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t GetInterfaceContextTableForHostName(
    const uint16_t* HostName,
    const uint16_t* ProxyName,
    uint32_t Flags,
    uint8_t* ConnectionProfileFilterRawData,
    uint32_t ConnectionProfileFilterRawDataSize,
    void* InterfaceContextTable);
C, "OnDemandConnRouteHelper.dll");
// $ffi->GetInterfaceContextTableForHostName(HostName, ProxyName, Flags, ConnectionProfileFilterRawData, ConnectionProfileFilterRawDataSize, InterfaceContextTable);
// HostName : LPCWSTR optional
// ProxyName : LPCWSTR optional
// Flags : DWORD
// ConnectionProfileFilterRawData : BYTE* optional
// ConnectionProfileFilterRawDataSize : DWORD
// InterfaceContextTable : NET_INTERFACE_CONTEXT_TABLE** 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 Ondemandconnroutehelper extends StdCallLibrary {
    Ondemandconnroutehelper INSTANCE = Native.load("ondemandconnroutehelper", Ondemandconnroutehelper.class);
    int GetInterfaceContextTableForHostName(
        WString HostName,   // LPCWSTR optional
        WString ProxyName,   // LPCWSTR optional
        int Flags,   // DWORD
        byte[] ConnectionProfileFilterRawData,   // BYTE* optional
        int ConnectionProfileFilterRawDataSize,   // DWORD
        Pointer InterfaceContextTable   // NET_INTERFACE_CONTEXT_TABLE** out
    );
}
@[Link("ondemandconnroutehelper")]
lib LibOnDemandConnRouteHelper
  fun GetInterfaceContextTableForHostName = GetInterfaceContextTableForHostName(
    HostName : UInt16*,   # LPCWSTR optional
    ProxyName : UInt16*,   # LPCWSTR optional
    Flags : UInt32,   # DWORD
    ConnectionProfileFilterRawData : UInt8*,   # BYTE* optional
    ConnectionProfileFilterRawDataSize : UInt32,   # DWORD
    InterfaceContextTable : NET_INTERFACE_CONTEXT_TABLE**   # NET_INTERFACE_CONTEXT_TABLE** out
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef GetInterfaceContextTableForHostNameNative = Int32 Function(Pointer<Utf16>, Pointer<Utf16>, Uint32, Pointer<Uint8>, Uint32, Pointer<Void>);
typedef GetInterfaceContextTableForHostNameDart = int Function(Pointer<Utf16>, Pointer<Utf16>, int, Pointer<Uint8>, int, Pointer<Void>);
final GetInterfaceContextTableForHostName = DynamicLibrary.open('OnDemandConnRouteHelper.dll')
    .lookupFunction<GetInterfaceContextTableForHostNameNative, GetInterfaceContextTableForHostNameDart>('GetInterfaceContextTableForHostName');
// HostName : LPCWSTR optional -> Pointer<Utf16>
// ProxyName : LPCWSTR optional -> Pointer<Utf16>
// Flags : DWORD -> Uint32
// ConnectionProfileFilterRawData : BYTE* optional -> Pointer<Uint8>
// ConnectionProfileFilterRawDataSize : DWORD -> Uint32
// InterfaceContextTable : NET_INTERFACE_CONTEXT_TABLE** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function GetInterfaceContextTableForHostName(
  HostName: PWideChar;   // LPCWSTR optional
  ProxyName: PWideChar;   // LPCWSTR optional
  Flags: DWORD;   // DWORD
  ConnectionProfileFilterRawData: Pointer;   // BYTE* optional
  ConnectionProfileFilterRawDataSize: DWORD;   // DWORD
  InterfaceContextTable: Pointer   // NET_INTERFACE_CONTEXT_TABLE** out
): Integer; stdcall;
  external 'OnDemandConnRouteHelper.dll' name 'GetInterfaceContextTableForHostName';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "GetInterfaceContextTableForHostName"
  c_GetInterfaceContextTableForHostName :: CWString -> CWString -> Word32 -> Ptr Word8 -> Word32 -> Ptr () -> IO Int32
-- HostName : LPCWSTR optional -> CWString
-- ProxyName : LPCWSTR optional -> CWString
-- Flags : DWORD -> Word32
-- ConnectionProfileFilterRawData : BYTE* optional -> Ptr Word8
-- ConnectionProfileFilterRawDataSize : DWORD -> Word32
-- InterfaceContextTable : NET_INTERFACE_CONTEXT_TABLE** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let getinterfacecontexttableforhostname =
  foreign "GetInterfaceContextTableForHostName"
    ((ptr uint16_t) @-> (ptr uint16_t) @-> uint32_t @-> (ptr uint8_t) @-> uint32_t @-> (ptr void) @-> returning int32_t)
(* HostName : LPCWSTR optional -> (ptr uint16_t) *)
(* ProxyName : LPCWSTR optional -> (ptr uint16_t) *)
(* Flags : DWORD -> uint32_t *)
(* ConnectionProfileFilterRawData : BYTE* optional -> (ptr uint8_t) *)
(* ConnectionProfileFilterRawDataSize : DWORD -> uint32_t *)
(* InterfaceContextTable : NET_INTERFACE_CONTEXT_TABLE** out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library ondemandconnroutehelper (t "OnDemandConnRouteHelper.dll"))
(cffi:use-foreign-library ondemandconnroutehelper)

(cffi:defcfun ("GetInterfaceContextTableForHostName" get-interface-context-table-for-host-name :convention :stdcall) :int32
  (host-name (:string :encoding :utf-16le))   ; LPCWSTR optional
  (proxy-name (:string :encoding :utf-16le))   ; LPCWSTR optional
  (flags :uint32)   ; DWORD
  (connection-profile-filter-raw-data :pointer)   ; BYTE* optional
  (connection-profile-filter-raw-data-size :uint32)   ; DWORD
  (interface-context-table :pointer))   ; NET_INTERFACE_CONTEXT_TABLE** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $GetInterfaceContextTableForHostName = Win32::API::More->new('OnDemandConnRouteHelper',
    'int GetInterfaceContextTableForHostName(LPCWSTR HostName, LPCWSTR ProxyName, DWORD Flags, LPVOID ConnectionProfileFilterRawData, DWORD ConnectionProfileFilterRawDataSize, LPVOID InterfaceContextTable)');
# my $ret = $GetInterfaceContextTableForHostName->Call($HostName, $ProxyName, $Flags, $ConnectionProfileFilterRawData, $ConnectionProfileFilterRawDataSize, $InterfaceContextTable);
# HostName : LPCWSTR optional -> LPCWSTR
# ProxyName : LPCWSTR optional -> LPCWSTR
# Flags : DWORD -> DWORD
# ConnectionProfileFilterRawData : BYTE* optional -> LPVOID
# ConnectionProfileFilterRawDataSize : DWORD -> DWORD
# InterfaceContextTable : NET_INTERFACE_CONTEXT_TABLE** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型