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

MDNS_QUERY_REQUEST

構造体
サイズx64: 64 バイト / x86: 48 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
VersionDWORD4+0+0構造体のバージョン番号を示す。
ulRefCountDWORD4+4+4リクエストの参照カウントを保持する。内部管理用。
QueryLPWSTR8/4+8+8mDNSで問い合わせる名前を表すワイド文字列ポインタ。
QueryTypeWORD2+16+12問い合わせるレコード種別を示すDNSタイプ値。
QueryOptionsULONGLONG8+24+16解決動作を制御するDNS_QUERY_OPTIONSフラグを保持する。
InterfaceIndexDWORD4+32+24問い合わせに使用するネットワークインターフェースのインデックス。0で全て。
pQueryCallbackPMDNS_QUERY_CALLBACK8/4+40+28結果受信時に呼ばれるmDNSコールバック関数のポインタ。
pQueryContextvoid*8/4+48+32コールバックに渡されるユーザ定義コンテキストポインタ。NULL可。
fAnswerReceivedBOOL4+56+36応答を受信済みか否かを示す真偽値。内部状態。
ulResendCountDWORD4+60+40クエリの再送回数を保持する。内部管理用。

各言語での定義

#include <windows.h>

// MDNS_QUERY_REQUEST  (x64 64 / x86 48 バイト)
typedef struct MDNS_QUERY_REQUEST {
    DWORD Version;
    DWORD ulRefCount;
    LPWSTR Query;
    WORD QueryType;
    ULONGLONG QueryOptions;
    DWORD InterfaceIndex;
    PMDNS_QUERY_CALLBACK pQueryCallback;
    void* pQueryContext;
    BOOL fAnswerReceived;
    DWORD ulResendCount;
} MDNS_QUERY_REQUEST;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct MDNS_QUERY_REQUEST
{
    public uint Version;
    public uint ulRefCount;
    public IntPtr Query;
    public ushort QueryType;
    public ulong QueryOptions;
    public uint InterfaceIndex;
    public IntPtr pQueryCallback;
    public IntPtr pQueryContext;
    [MarshalAs(UnmanagedType.Bool)] public bool fAnswerReceived;
    public uint ulResendCount;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure MDNS_QUERY_REQUEST
    Public Version As UInteger
    Public ulRefCount As UInteger
    Public Query As IntPtr
    Public QueryType As UShort
    Public QueryOptions As ULong
    Public InterfaceIndex As UInteger
    Public pQueryCallback As IntPtr
    Public pQueryContext As IntPtr
    <MarshalAs(UnmanagedType.Bool)> Public fAnswerReceived As Boolean
    Public ulResendCount As UInteger
End Structure
import ctypes
from ctypes import wintypes

class MDNS_QUERY_REQUEST(ctypes.Structure):
    _fields_ = [
        ("Version", wintypes.DWORD),
        ("ulRefCount", wintypes.DWORD),
        ("Query", ctypes.c_void_p),
        ("QueryType", ctypes.c_ushort),
        ("QueryOptions", ctypes.c_ulonglong),
        ("InterfaceIndex", wintypes.DWORD),
        ("pQueryCallback", ctypes.c_void_p),
        ("pQueryContext", ctypes.c_void_p),
        ("fAnswerReceived", wintypes.BOOL),
        ("ulResendCount", wintypes.DWORD),
    ]
#[repr(C)]
pub struct MDNS_QUERY_REQUEST {
    pub Version: u32,
    pub ulRefCount: u32,
    pub Query: *mut core::ffi::c_void,
    pub QueryType: u16,
    pub QueryOptions: u64,
    pub InterfaceIndex: u32,
    pub pQueryCallback: *mut core::ffi::c_void,
    pub pQueryContext: *mut core::ffi::c_void,
    pub fAnswerReceived: i32,
    pub ulResendCount: u32,
}
import "golang.org/x/sys/windows"

type MDNS_QUERY_REQUEST struct {
	Version uint32
	ulRefCount uint32
	Query uintptr
	QueryType uint16
	QueryOptions uint64
	InterfaceIndex uint32
	pQueryCallback uintptr
	pQueryContext uintptr
	fAnswerReceived int32
	ulResendCount uint32
}
type
  MDNS_QUERY_REQUEST = record
    Version: DWORD;
    ulRefCount: DWORD;
    Query: Pointer;
    QueryType: Word;
    QueryOptions: UInt64;
    InterfaceIndex: DWORD;
    pQueryCallback: Pointer;
    pQueryContext: Pointer;
    fAnswerReceived: BOOL;
    ulResendCount: DWORD;
  end;
const MDNS_QUERY_REQUEST = extern struct {
    Version: u32,
    ulRefCount: u32,
    Query: ?*anyopaque,
    QueryType: u16,
    QueryOptions: u64,
    InterfaceIndex: u32,
    pQueryCallback: ?*anyopaque,
    pQueryContext: ?*anyopaque,
    fAnswerReceived: i32,
    ulResendCount: u32,
};
type
  MDNS_QUERY_REQUEST {.bycopy.} = object
    Version: uint32
    ulRefCount: uint32
    Query: pointer
    QueryType: uint16
    QueryOptions: uint64
    InterfaceIndex: uint32
    pQueryCallback: pointer
    pQueryContext: pointer
    fAnswerReceived: int32
    ulResendCount: uint32
struct MDNS_QUERY_REQUEST
{
    uint Version;
    uint ulRefCount;
    void* Query;
    ushort QueryType;
    ulong QueryOptions;
    uint InterfaceIndex;
    void* pQueryCallback;
    void* pQueryContext;
    int fAnswerReceived;
    uint ulResendCount;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; MDNS_QUERY_REQUEST サイズ: 48 バイト(x86)
dim st, 12    ; 4byte整数×12(構造体サイズ 48 / 4 切り上げ)
; Version : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; ulRefCount : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; Query : LPWSTR (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; QueryType : WORD (+12, 2byte)  wpoke st,12,値  /  値 = wpeek(st,12)
; QueryOptions : ULONGLONG (+16, 8byte)  qpoke st,16,値 / qpeek(st,16)  ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; InterfaceIndex : DWORD (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; pQueryCallback : PMDNS_QUERY_CALLBACK (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; pQueryContext : void* (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; fAnswerReceived : BOOL (+36, 4byte)  st.9 = 値  /  値 = st.9   (lpoke/lpeek も可)
; ulResendCount : DWORD (+40, 4byte)  st.10 = 値  /  値 = st.10   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; MDNS_QUERY_REQUEST サイズ: 64 バイト(x64)
dim st, 16    ; 4byte整数×16(構造体サイズ 64 / 4 切り上げ)
; Version : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; ulRefCount : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; Query : LPWSTR (+8, 8byte)  qpoke st,8,値 / qpeek(st,8)  ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; QueryType : WORD (+16, 2byte)  wpoke st,16,値  /  値 = wpeek(st,16)
; QueryOptions : ULONGLONG (+24, 8byte)  qpoke st,24,値 / qpeek(st,24)  ※IronHSPのみ。3.7/3.8は lpoke st,24,下位 : lpoke st,28,上位
; InterfaceIndex : DWORD (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; pQueryCallback : PMDNS_QUERY_CALLBACK (+40, 8byte)  qpoke st,40,値 / qpeek(st,40)  ※IronHSPのみ。3.7/3.8は lpoke st,40,下位 : lpoke st,44,上位
; pQueryContext : void* (+48, 8byte)  qpoke st,48,値 / qpeek(st,48)  ※IronHSPのみ。3.7/3.8は lpoke st,48,下位 : lpoke st,52,上位
; fAnswerReceived : BOOL (+56, 4byte)  st.14 = 値  /  値 = st.14   (lpoke/lpeek も可)
; ulResendCount : DWORD (+60, 4byte)  st.15 = 値  /  値 = st.15   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global MDNS_QUERY_REQUEST
    #field int Version
    #field int ulRefCount
    #field intptr Query
    #field short QueryType
    #field int64 QueryOptions
    #field int InterfaceIndex
    #field intptr pQueryCallback
    #field intptr pQueryContext
    #field bool fAnswerReceived
    #field int ulResendCount
#endstruct

stdim st, MDNS_QUERY_REQUEST        ; NSTRUCT 変数を確保
st->Version = 100
mes "Version=" + st->Version