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

MprConfigInterfaceGetHandle

関数
指定名のインターフェイスのハンドルを構成から取得する。
DLLMPRAPI.dll呼出規約winapi対応OSwindowsserver2000

シグネチャ

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

DWORD MprConfigInterfaceGetHandle(
    HANDLE hMprConfig,
    LPWSTR lpwsInterfaceName,
    HANDLE* phRouterInterface
);

パラメーター

名前方向
hMprConfigHANDLEin
lpwsInterfaceNameLPWSTRin
phRouterInterfaceHANDLE*out

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD MprConfigInterfaceGetHandle(
    HANDLE hMprConfig,
    LPWSTR lpwsInterfaceName,
    HANDLE* phRouterInterface
);
[DllImport("MPRAPI.dll", ExactSpelling = true)]
static extern uint MprConfigInterfaceGetHandle(
    IntPtr hMprConfig,   // HANDLE
    [MarshalAs(UnmanagedType.LPWStr)] string lpwsInterfaceName,   // LPWSTR
    IntPtr phRouterInterface   // HANDLE* out
);
<DllImport("MPRAPI.dll", ExactSpelling:=True)>
Public Shared Function MprConfigInterfaceGetHandle(
    hMprConfig As IntPtr,   ' HANDLE
    <MarshalAs(UnmanagedType.LPWStr)> lpwsInterfaceName As String,   ' LPWSTR
    phRouterInterface As IntPtr   ' HANDLE* out
) As UInteger
End Function
' hMprConfig : HANDLE
' lpwsInterfaceName : LPWSTR
' phRouterInterface : HANDLE* out
Declare PtrSafe Function MprConfigInterfaceGetHandle Lib "mprapi" ( _
    ByVal hMprConfig As LongPtr, _
    ByVal lpwsInterfaceName As LongPtr, _
    ByVal phRouterInterface As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

MprConfigInterfaceGetHandle = ctypes.windll.mprapi.MprConfigInterfaceGetHandle
MprConfigInterfaceGetHandle.restype = wintypes.DWORD
MprConfigInterfaceGetHandle.argtypes = [
    wintypes.HANDLE,  # hMprConfig : HANDLE
    wintypes.LPCWSTR,  # lpwsInterfaceName : LPWSTR
    ctypes.c_void_p,  # phRouterInterface : HANDLE* out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('MPRAPI.dll')
MprConfigInterfaceGetHandle = Fiddle::Function.new(
  lib['MprConfigInterfaceGetHandle'],
  [
    Fiddle::TYPE_VOIDP,  # hMprConfig : HANDLE
    Fiddle::TYPE_VOIDP,  # lpwsInterfaceName : LPWSTR
    Fiddle::TYPE_VOIDP,  # phRouterInterface : HANDLE* out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "mprapi")]
extern "system" {
    fn MprConfigInterfaceGetHandle(
        hMprConfig: *mut core::ffi::c_void,  // HANDLE
        lpwsInterfaceName: *mut u16,  // LPWSTR
        phRouterInterface: *mut *mut core::ffi::c_void  // HANDLE* out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("MPRAPI.dll")]
public static extern uint MprConfigInterfaceGetHandle(IntPtr hMprConfig, [MarshalAs(UnmanagedType.LPWStr)] string lpwsInterfaceName, IntPtr phRouterInterface);
"@
$api = Add-Type -MemberDefinition $sig -Name 'MPRAPI_MprConfigInterfaceGetHandle' -Namespace Win32 -PassThru
# $api::MprConfigInterfaceGetHandle(hMprConfig, lpwsInterfaceName, phRouterInterface)
#uselib "MPRAPI.dll"
#func global MprConfigInterfaceGetHandle "MprConfigInterfaceGetHandle" sptr, sptr, sptr
; MprConfigInterfaceGetHandle hMprConfig, lpwsInterfaceName, phRouterInterface   ; 戻り値は stat
; hMprConfig : HANDLE -> "sptr"
; lpwsInterfaceName : LPWSTR -> "sptr"
; phRouterInterface : HANDLE* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "MPRAPI.dll"
#cfunc global MprConfigInterfaceGetHandle "MprConfigInterfaceGetHandle" sptr, wstr, sptr
; res = MprConfigInterfaceGetHandle(hMprConfig, lpwsInterfaceName, phRouterInterface)
; hMprConfig : HANDLE -> "sptr"
; lpwsInterfaceName : LPWSTR -> "wstr"
; phRouterInterface : HANDLE* out -> "sptr"
; DWORD MprConfigInterfaceGetHandle(HANDLE hMprConfig, LPWSTR lpwsInterfaceName, HANDLE* phRouterInterface)
#uselib "MPRAPI.dll"
#cfunc global MprConfigInterfaceGetHandle "MprConfigInterfaceGetHandle" intptr, wstr, intptr
; res = MprConfigInterfaceGetHandle(hMprConfig, lpwsInterfaceName, phRouterInterface)
; hMprConfig : HANDLE -> "intptr"
; lpwsInterfaceName : LPWSTR -> "wstr"
; phRouterInterface : HANDLE* out -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	mprapi = windows.NewLazySystemDLL("MPRAPI.dll")
	procMprConfigInterfaceGetHandle = mprapi.NewProc("MprConfigInterfaceGetHandle")
)

// hMprConfig (HANDLE), lpwsInterfaceName (LPWSTR), phRouterInterface (HANDLE* out)
r1, _, err := procMprConfigInterfaceGetHandle.Call(
	uintptr(hMprConfig),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpwsInterfaceName))),
	uintptr(phRouterInterface),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function MprConfigInterfaceGetHandle(
  hMprConfig: THandle;   // HANDLE
  lpwsInterfaceName: PWideChar;   // LPWSTR
  phRouterInterface: Pointer   // HANDLE* out
): DWORD; stdcall;
  external 'MPRAPI.dll' name 'MprConfigInterfaceGetHandle';
result := DllCall("MPRAPI\MprConfigInterfaceGetHandle"
    , "Ptr", hMprConfig   ; HANDLE
    , "WStr", lpwsInterfaceName   ; LPWSTR
    , "Ptr", phRouterInterface   ; HANDLE* out
    , "UInt")   ; return: DWORD
●MprConfigInterfaceGetHandle(hMprConfig, lpwsInterfaceName, phRouterInterface) = DLL("MPRAPI.dll", "dword MprConfigInterfaceGetHandle(void*, char*, void*)")
# 呼び出し: MprConfigInterfaceGetHandle(hMprConfig, lpwsInterfaceName, phRouterInterface)
# hMprConfig : HANDLE -> "void*"
# lpwsInterfaceName : LPWSTR -> "char*"
# phRouterInterface : HANDLE* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。