ホーム › NetworkManagement.WindowsConnectionManager › GetInterfaceContextTableForHostName
GetInterfaceContextTableForHostName
関数指定ホスト名に対応するインターフェイスコンテキストテーブルを取得する。
シグネチャ
// 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
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| HostName | LPCWSTR | inoptional |
| ProxyName | LPCWSTR | inoptional |
| Flags | DWORD | in |
| ConnectionProfileFilterRawData | BYTE* | inoptional |
| ConnectionProfileFilterRawDataSize | DWORD | in |
| InterfaceContextTable | NET_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 方式にも切替可。#uselib "OnDemandConnRouteHelper.dll" #cfunc global GetInterfaceContextTableForHostName "GetInterfaceContextTableForHostName" wstr, wstr, int, sptr, int, sptr ; res = GetInterfaceContextTableForHostName(HostName, ProxyName, Flags, varptr(ConnectionProfileFilterRawData), ConnectionProfileFilterRawDataSize, varptr(InterfaceContextTable)) ; HostName : LPCWSTR optional -> "wstr" ; ProxyName : LPCWSTR optional -> "wstr" ; Flags : DWORD -> "int" ; ConnectionProfileFilterRawData : BYTE* optional -> "sptr" ; ConnectionProfileFilterRawDataSize : DWORD -> "int" ; InterfaceContextTable : NET_INTERFACE_CONTEXT_TABLE** out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは 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 方式にも切替可。; 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, intptr, int, intptr ; res = GetInterfaceContextTableForHostName(HostName, ProxyName, Flags, varptr(ConnectionProfileFilterRawData), ConnectionProfileFilterRawDataSize, varptr(InterfaceContextTable)) ; HostName : LPCWSTR optional -> "wstr" ; ProxyName : LPCWSTR optional -> "wstr" ; Flags : DWORD -> "int" ; ConnectionProfileFilterRawData : BYTE* optional -> "intptr" ; ConnectionProfileFilterRawDataSize : DWORD -> "int" ; InterfaceContextTable : NET_INTERFACE_CONTEXT_TABLE** out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは 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 // HRESULTfunction 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)。