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