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

DnsStopMulticastQuery

関数
実行中のマルチキャストDNS問い合わせを停止する。
DLLDNSAPI.dll呼出規約winapiSetLastErrorあり対応OSWindows 10 以降

シグネチャ

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

INT DnsStopMulticastQuery(
    MDNS_QUERY_HANDLE* pHandle
);

パラメーター

名前方向
pHandleMDNS_QUERY_HANDLE*inout

戻り値の型: INT

各言語での呼び出し定義

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

INT DnsStopMulticastQuery(
    MDNS_QUERY_HANDLE* pHandle
);
[DllImport("DNSAPI.dll", SetLastError = true, ExactSpelling = true)]
static extern int DnsStopMulticastQuery(
    IntPtr pHandle   // MDNS_QUERY_HANDLE* in/out
);
<DllImport("DNSAPI.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function DnsStopMulticastQuery(
    pHandle As IntPtr   ' MDNS_QUERY_HANDLE* in/out
) As Integer
End Function
' pHandle : MDNS_QUERY_HANDLE* in/out
Declare PtrSafe Function DnsStopMulticastQuery Lib "dnsapi" ( _
    ByVal pHandle As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

DnsStopMulticastQuery = ctypes.windll.dnsapi.DnsStopMulticastQuery
DnsStopMulticastQuery.restype = ctypes.c_int
DnsStopMulticastQuery.argtypes = [
    ctypes.c_void_p,  # pHandle : MDNS_QUERY_HANDLE* in/out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('DNSAPI.dll')
DnsStopMulticastQuery = Fiddle::Function.new(
  lib['DnsStopMulticastQuery'],
  [
    Fiddle::TYPE_VOIDP,  # pHandle : MDNS_QUERY_HANDLE* in/out
  ],
  Fiddle::TYPE_INT)
#[link(name = "dnsapi")]
extern "system" {
    fn DnsStopMulticastQuery(
        pHandle: *mut MDNS_QUERY_HANDLE  // MDNS_QUERY_HANDLE* in/out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("DNSAPI.dll", SetLastError = true)]
public static extern int DnsStopMulticastQuery(IntPtr pHandle);
"@
$api = Add-Type -MemberDefinition $sig -Name 'DNSAPI_DnsStopMulticastQuery' -Namespace Win32 -PassThru
# $api::DnsStopMulticastQuery(pHandle)
#uselib "DNSAPI.dll"
#func global DnsStopMulticastQuery "DnsStopMulticastQuery" sptr
; DnsStopMulticastQuery varptr(pHandle)   ; 戻り値は stat
; pHandle : MDNS_QUERY_HANDLE* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "DNSAPI.dll"
#cfunc global DnsStopMulticastQuery "DnsStopMulticastQuery" var
; res = DnsStopMulticastQuery(pHandle)
; pHandle : MDNS_QUERY_HANDLE* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; INT DnsStopMulticastQuery(MDNS_QUERY_HANDLE* pHandle)
#uselib "DNSAPI.dll"
#cfunc global DnsStopMulticastQuery "DnsStopMulticastQuery" var
; res = DnsStopMulticastQuery(pHandle)
; pHandle : MDNS_QUERY_HANDLE* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	dnsapi = windows.NewLazySystemDLL("DNSAPI.dll")
	procDnsStopMulticastQuery = dnsapi.NewProc("DnsStopMulticastQuery")
)

// pHandle (MDNS_QUERY_HANDLE* in/out)
r1, _, err := procDnsStopMulticastQuery.Call(
	uintptr(pHandle),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // INT
function DnsStopMulticastQuery(
  pHandle: Pointer   // MDNS_QUERY_HANDLE* in/out
): Integer; stdcall;
  external 'DNSAPI.dll' name 'DnsStopMulticastQuery';
result := DllCall("DNSAPI\DnsStopMulticastQuery"
    , "Ptr", pHandle   ; MDNS_QUERY_HANDLE* in/out
    , "Int")   ; return: INT
●DnsStopMulticastQuery(pHandle) = DLL("DNSAPI.dll", "int DnsStopMulticastQuery(void*)")
# 呼び出し: DnsStopMulticastQuery(pHandle)
# pHandle : MDNS_QUERY_HANDLE* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。