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

DNS_QUERY_REQUEST3

構造体
サイズx64: 88 バイト / x86: 56 バイト

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

フィールド

フィールドサイズx64x86説明
VersionDWORD4+0+0構造体のバージョン番号を示す。バージョン3を指定する。
QueryNameLPWSTR8/4+8+4問い合わせるドメイン名を表すワイド文字列ポインタ。
QueryTypeWORD2+16+8問い合わせるレコード種別を示すDNSタイプ値。
QueryOptionsULONGLONG8+24+16解決動作を制御するDNS_QUERY_OPTIONSフラグを保持する。
pDnsServerListDNS_ADDR_ARRAY*8/4+32+24使用するDNSサーバ一覧を指すポインタ。NULLで既定サーバを使用。
InterfaceIndexDWORD4+40+28問い合わせに使用するネットワークインターフェースのインデックス。0で自動選択。
pQueryCompletionCallbackPDNS_QUERY_COMPLETION_ROUTINE8/4+48+32非同期完了時に呼ばれるコールバック関数のポインタ。
pQueryContextvoid*8/4+56+36コールバックに渡されるユーザ定義コンテキストポインタ。NULL可。
IsNetworkQueryRequiredBOOL4+64+40特定ネットワーク経由の問い合わせを必須とするか否かを示す真偽値。
RequiredNetworkIndexDWORD4+68+44問い合わせを必須とするネットワークのインデックスを示す。
cCustomServersDWORD4+72+48pCustomServersが指すカスタムサーバ要素数を示す。
pCustomServersDNS_CUSTOM_SERVER*8/4+80+52使用するカスタムDNSサーバ配列を指すポインタ。NULL可。

各言語での定義

#include <windows.h>

// DNS_QUERY_REQUEST3  (x64 88 / x86 56 バイト)
typedef struct DNS_QUERY_REQUEST3 {
    DWORD Version;
    LPWSTR QueryName;
    WORD QueryType;
    ULONGLONG QueryOptions;
    DNS_ADDR_ARRAY* pDnsServerList;
    DWORD InterfaceIndex;
    PDNS_QUERY_COMPLETION_ROUTINE pQueryCompletionCallback;
    void* pQueryContext;
    BOOL IsNetworkQueryRequired;
    DWORD RequiredNetworkIndex;
    DWORD cCustomServers;
    DNS_CUSTOM_SERVER* pCustomServers;
} DNS_QUERY_REQUEST3;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DNS_QUERY_REQUEST3
{
    public uint Version;
    public IntPtr QueryName;
    public ushort QueryType;
    public ulong QueryOptions;
    public IntPtr pDnsServerList;
    public uint InterfaceIndex;
    public IntPtr pQueryCompletionCallback;
    public IntPtr pQueryContext;
    [MarshalAs(UnmanagedType.Bool)] public bool IsNetworkQueryRequired;
    public uint RequiredNetworkIndex;
    public uint cCustomServers;
    public IntPtr pCustomServers;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DNS_QUERY_REQUEST3
    Public Version As UInteger
    Public QueryName As IntPtr
    Public QueryType As UShort
    Public QueryOptions As ULong
    Public pDnsServerList As IntPtr
    Public InterfaceIndex As UInteger
    Public pQueryCompletionCallback As IntPtr
    Public pQueryContext As IntPtr
    <MarshalAs(UnmanagedType.Bool)> Public IsNetworkQueryRequired As Boolean
    Public RequiredNetworkIndex As UInteger
    Public cCustomServers As UInteger
    Public pCustomServers As IntPtr
End Structure
import ctypes
from ctypes import wintypes

class DNS_QUERY_REQUEST3(ctypes.Structure):
    _fields_ = [
        ("Version", wintypes.DWORD),
        ("QueryName", ctypes.c_void_p),
        ("QueryType", ctypes.c_ushort),
        ("QueryOptions", ctypes.c_ulonglong),
        ("pDnsServerList", ctypes.c_void_p),
        ("InterfaceIndex", wintypes.DWORD),
        ("pQueryCompletionCallback", ctypes.c_void_p),
        ("pQueryContext", ctypes.c_void_p),
        ("IsNetworkQueryRequired", wintypes.BOOL),
        ("RequiredNetworkIndex", wintypes.DWORD),
        ("cCustomServers", wintypes.DWORD),
        ("pCustomServers", ctypes.c_void_p),
    ]
#[repr(C)]
pub struct DNS_QUERY_REQUEST3 {
    pub Version: u32,
    pub QueryName: *mut core::ffi::c_void,
    pub QueryType: u16,
    pub QueryOptions: u64,
    pub pDnsServerList: *mut core::ffi::c_void,
    pub InterfaceIndex: u32,
    pub pQueryCompletionCallback: *mut core::ffi::c_void,
    pub pQueryContext: *mut core::ffi::c_void,
    pub IsNetworkQueryRequired: i32,
    pub RequiredNetworkIndex: u32,
    pub cCustomServers: u32,
    pub pCustomServers: *mut core::ffi::c_void,
}
import "golang.org/x/sys/windows"

type DNS_QUERY_REQUEST3 struct {
	Version uint32
	QueryName uintptr
	QueryType uint16
	QueryOptions uint64
	pDnsServerList uintptr
	InterfaceIndex uint32
	pQueryCompletionCallback uintptr
	pQueryContext uintptr
	IsNetworkQueryRequired int32
	RequiredNetworkIndex uint32
	cCustomServers uint32
	pCustomServers uintptr
}
type
  DNS_QUERY_REQUEST3 = record
    Version: DWORD;
    QueryName: Pointer;
    QueryType: Word;
    QueryOptions: UInt64;
    pDnsServerList: Pointer;
    InterfaceIndex: DWORD;
    pQueryCompletionCallback: Pointer;
    pQueryContext: Pointer;
    IsNetworkQueryRequired: BOOL;
    RequiredNetworkIndex: DWORD;
    cCustomServers: DWORD;
    pCustomServers: Pointer;
  end;
const DNS_QUERY_REQUEST3 = extern struct {
    Version: u32,
    QueryName: ?*anyopaque,
    QueryType: u16,
    QueryOptions: u64,
    pDnsServerList: ?*anyopaque,
    InterfaceIndex: u32,
    pQueryCompletionCallback: ?*anyopaque,
    pQueryContext: ?*anyopaque,
    IsNetworkQueryRequired: i32,
    RequiredNetworkIndex: u32,
    cCustomServers: u32,
    pCustomServers: ?*anyopaque,
};
type
  DNS_QUERY_REQUEST3 {.bycopy.} = object
    Version: uint32
    QueryName: pointer
    QueryType: uint16
    QueryOptions: uint64
    pDnsServerList: pointer
    InterfaceIndex: uint32
    pQueryCompletionCallback: pointer
    pQueryContext: pointer
    IsNetworkQueryRequired: int32
    RequiredNetworkIndex: uint32
    cCustomServers: uint32
    pCustomServers: pointer
struct DNS_QUERY_REQUEST3
{
    uint Version;
    void* QueryName;
    ushort QueryType;
    ulong QueryOptions;
    void* pDnsServerList;
    uint InterfaceIndex;
    void* pQueryCompletionCallback;
    void* pQueryContext;
    int IsNetworkQueryRequired;
    uint RequiredNetworkIndex;
    uint cCustomServers;
    void* pCustomServers;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; DNS_QUERY_REQUEST3 サイズ: 56 バイト(x86)
dim st, 14    ; 4byte整数×14(構造体サイズ 56 / 4 切り上げ)
; Version : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; QueryName : LPWSTR (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; QueryType : WORD (+8, 2byte)  wpoke st,8,値  /  値 = wpeek(st,8)
; QueryOptions : ULONGLONG (+16, 8byte)  qpoke st,16,値 / qpeek(st,16)  ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; pDnsServerList : DNS_ADDR_ARRAY* (+24, 4byte)  varptr(st)+24 を基点に操作(4byte:入れ子/配列)
; InterfaceIndex : DWORD (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; pQueryCompletionCallback : PDNS_QUERY_COMPLETION_ROUTINE (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; pQueryContext : void* (+36, 4byte)  st.9 = 値  /  値 = st.9   (lpoke/lpeek も可)
; IsNetworkQueryRequired : BOOL (+40, 4byte)  st.10 = 値  /  値 = st.10   (lpoke/lpeek も可)
; RequiredNetworkIndex : DWORD (+44, 4byte)  st.11 = 値  /  値 = st.11   (lpoke/lpeek も可)
; cCustomServers : DWORD (+48, 4byte)  st.12 = 値  /  値 = st.12   (lpoke/lpeek も可)
; pCustomServers : DNS_CUSTOM_SERVER* (+52, 4byte)  varptr(st)+52 を基点に操作(4byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; DNS_QUERY_REQUEST3 サイズ: 88 バイト(x64)
dim st, 22    ; 4byte整数×22(構造体サイズ 88 / 4 切り上げ)
; Version : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; QueryName : 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,上位
; pDnsServerList : DNS_ADDR_ARRAY* (+32, 8byte)  varptr(st)+32 を基点に操作(8byte:入れ子/配列)
; InterfaceIndex : DWORD (+40, 4byte)  st.10 = 値  /  値 = st.10   (lpoke/lpeek も可)
; pQueryCompletionCallback : PDNS_QUERY_COMPLETION_ROUTINE (+48, 8byte)  qpoke st,48,値 / qpeek(st,48)  ※IronHSPのみ。3.7/3.8は lpoke st,48,下位 : lpoke st,52,上位
; pQueryContext : void* (+56, 8byte)  qpoke st,56,値 / qpeek(st,56)  ※IronHSPのみ。3.7/3.8は lpoke st,56,下位 : lpoke st,60,上位
; IsNetworkQueryRequired : BOOL (+64, 4byte)  st.16 = 値  /  値 = st.16   (lpoke/lpeek も可)
; RequiredNetworkIndex : DWORD (+68, 4byte)  st.17 = 値  /  値 = st.17   (lpoke/lpeek も可)
; cCustomServers : DWORD (+72, 4byte)  st.18 = 値  /  値 = st.18   (lpoke/lpeek も可)
; pCustomServers : DNS_CUSTOM_SERVER* (+80, 8byte)  varptr(st)+80 を基点に操作(8byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global DNS_QUERY_REQUEST3
    #field int Version
    #field intptr QueryName
    #field short QueryType
    #field int64 QueryOptions
    #field intptr pDnsServerList
    #field int InterfaceIndex
    #field intptr pQueryCompletionCallback
    #field intptr pQueryContext
    #field bool IsNetworkQueryRequired
    #field int RequiredNetworkIndex
    #field int cCustomServers
    #field intptr pCustomServers
#endstruct

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