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