ホーム › NetworkManagement.IpHelper › GetInterfaceDnsSettings
GetInterfaceDnsSettings
関数指定したインターフェイスのDNS設定を取得する。
シグネチャ
// IPHLPAPI.dll
#include <windows.h>
WIN32_ERROR GetInterfaceDnsSettings(
GUID Interface,
DNS_INTERFACE_SETTINGS* Settings
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| Interface | GUID | in |
| Settings | DNS_INTERFACE_SETTINGS* | inout |
戻り値の型: WIN32_ERROR
各言語での呼び出し定義
// IPHLPAPI.dll
#include <windows.h>
WIN32_ERROR GetInterfaceDnsSettings(
GUID Interface,
DNS_INTERFACE_SETTINGS* Settings
);[DllImport("IPHLPAPI.dll", ExactSpelling = true)]
static extern uint GetInterfaceDnsSettings(
Guid Interface, // GUID
IntPtr Settings // DNS_INTERFACE_SETTINGS* in/out
);<DllImport("IPHLPAPI.dll", ExactSpelling:=True)>
Public Shared Function GetInterfaceDnsSettings(
[Interface] As Guid, ' GUID
Settings As IntPtr ' DNS_INTERFACE_SETTINGS* in/out
) As UInteger
End Function' Interface : GUID
' Settings : DNS_INTERFACE_SETTINGS* in/out
Declare PtrSafe Function GetInterfaceDnsSettings Lib "iphlpapi" ( _
ByVal Interface As LongPtr, _
ByVal Settings As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetInterfaceDnsSettings = ctypes.windll.iphlpapi.GetInterfaceDnsSettings
GetInterfaceDnsSettings.restype = wintypes.DWORD
GetInterfaceDnsSettings.argtypes = [
ctypes.c_void_p, # Interface : GUID
ctypes.c_void_p, # Settings : DNS_INTERFACE_SETTINGS* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('IPHLPAPI.dll')
GetInterfaceDnsSettings = Fiddle::Function.new(
lib['GetInterfaceDnsSettings'],
[
Fiddle::TYPE_VOIDP, # Interface : GUID
Fiddle::TYPE_VOIDP, # Settings : DNS_INTERFACE_SETTINGS* in/out
],
-Fiddle::TYPE_INT)#[link(name = "iphlpapi")]
extern "system" {
fn GetInterfaceDnsSettings(
Interface: GUID, // GUID
Settings: *mut DNS_INTERFACE_SETTINGS // DNS_INTERFACE_SETTINGS* in/out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("IPHLPAPI.dll")]
public static extern uint GetInterfaceDnsSettings(Guid Interface, IntPtr Settings);
"@
$api = Add-Type -MemberDefinition $sig -Name 'IPHLPAPI_GetInterfaceDnsSettings' -Namespace Win32 -PassThru
# $api::GetInterfaceDnsSettings(Interface, Settings)#uselib "IPHLPAPI.dll"
#func global GetInterfaceDnsSettings "GetInterfaceDnsSettings" sptr, sptr
; GetInterfaceDnsSettings Interface, varptr(Settings) ; 戻り値は stat
; Interface : GUID -> "sptr"
; Settings : DNS_INTERFACE_SETTINGS* in/out -> "sptr"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "IPHLPAPI.dll" #cfunc global GetInterfaceDnsSettings "GetInterfaceDnsSettings" int, var ; res = GetInterfaceDnsSettings(Interface, Settings) ; Interface : GUID -> "int" ; Settings : DNS_INTERFACE_SETTINGS* in/out -> "var" ; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。 ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "IPHLPAPI.dll" #cfunc global GetInterfaceDnsSettings "GetInterfaceDnsSettings" int, sptr ; res = GetInterfaceDnsSettings(Interface, varptr(Settings)) ; Interface : GUID -> "int" ; Settings : DNS_INTERFACE_SETTINGS* in/out -> "sptr" ; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。 ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; WIN32_ERROR GetInterfaceDnsSettings(GUID Interface, DNS_INTERFACE_SETTINGS* Settings) #uselib "IPHLPAPI.dll" #cfunc global GetInterfaceDnsSettings "GetInterfaceDnsSettings" int, var ; res = GetInterfaceDnsSettings(Interface, Settings) ; Interface : GUID -> "int" ; Settings : DNS_INTERFACE_SETTINGS* in/out -> "var" ; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。 ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; WIN32_ERROR GetInterfaceDnsSettings(GUID Interface, DNS_INTERFACE_SETTINGS* Settings) #uselib "IPHLPAPI.dll" #cfunc global GetInterfaceDnsSettings "GetInterfaceDnsSettings" int, intptr ; res = GetInterfaceDnsSettings(Interface, varptr(Settings)) ; Interface : GUID -> "int" ; Settings : DNS_INTERFACE_SETTINGS* in/out -> "intptr" ; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。 ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
iphlpapi = windows.NewLazySystemDLL("IPHLPAPI.dll")
procGetInterfaceDnsSettings = iphlpapi.NewProc("GetInterfaceDnsSettings")
)
// Interface (GUID), Settings (DNS_INTERFACE_SETTINGS* in/out)
r1, _, err := procGetInterfaceDnsSettings.Call(
uintptr(Interface),
uintptr(Settings),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // WIN32_ERRORfunction GetInterfaceDnsSettings(
Interface: TGUID; // GUID
Settings: Pointer // DNS_INTERFACE_SETTINGS* in/out
): DWORD; stdcall;
external 'IPHLPAPI.dll' name 'GetInterfaceDnsSettings';result := DllCall("IPHLPAPI\GetInterfaceDnsSettings"
, "Ptr", Interface ; GUID
, "Ptr", Settings ; DNS_INTERFACE_SETTINGS* in/out
, "UInt") ; return: WIN32_ERROR●GetInterfaceDnsSettings(Interface, Settings) = DLL("IPHLPAPI.dll", "dword GetInterfaceDnsSettings(void*, void*)")
# 呼び出し: GetInterfaceDnsSettings(Interface, Settings)
# Interface : GUID -> "void*"
# Settings : DNS_INTERFACE_SETTINGS* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。