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

DNS_SERVER_PROPERTY

構造体
サイズx64: 24 バイト / x86: 16 バイト

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

フィールド

フィールドサイズx64x86説明
VersionDWORD4+0+0この構造体のバージョン番号を示す。
ServerIndexDWORD4+4+4対象となるDNSサーバーのインデックスである。
TypeDNS_SERVER_PROPERTY_TYPE4+8+8プロパティの種別(DNS_SERVER_PROPERTY_TYPE、DoH/DoT等)を示す。
PropertyDNS_SERVER_PROPERTY_TYPES8/4+16+12種別に応じた設定データを保持するDNS_SERVER_PROPERTY_TYPES共用体である。

各言語での定義

#include <windows.h>

// DNS_SERVER_PROPERTY_TYPES  (x64 8 / x86 4 バイト)
typedef struct DNS_SERVER_PROPERTY_TYPES {
    DNS_DOH_SERVER_SETTINGS* DohSettings;
    DNS_DOT_SERVER_SETTINGS* DotSettings;
} DNS_SERVER_PROPERTY_TYPES;

// DNS_SERVER_PROPERTY  (x64 24 / x86 16 バイト)
typedef struct DNS_SERVER_PROPERTY {
    DWORD Version;
    DWORD ServerIndex;
    DNS_SERVER_PROPERTY_TYPE Type;
    DNS_SERVER_PROPERTY_TYPES Property;
} DNS_SERVER_PROPERTY;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DNS_SERVER_PROPERTY_TYPES
{
    public IntPtr DohSettings;
    public IntPtr DotSettings;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DNS_SERVER_PROPERTY
{
    public uint Version;
    public uint ServerIndex;
    public int Type;
    public DNS_SERVER_PROPERTY_TYPES Property;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DNS_SERVER_PROPERTY_TYPES
    Public DohSettings As IntPtr
    Public DotSettings As IntPtr
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DNS_SERVER_PROPERTY
    Public Version As UInteger
    Public ServerIndex As UInteger
    Public Type As Integer
    Public Property As DNS_SERVER_PROPERTY_TYPES
End Structure
import ctypes
from ctypes import wintypes

class DNS_SERVER_PROPERTY_TYPES(ctypes.Structure):
    _fields_ = [
        ("DohSettings", ctypes.c_void_p),
        ("DotSettings", ctypes.c_void_p),
    ]

class DNS_SERVER_PROPERTY(ctypes.Structure):
    _fields_ = [
        ("Version", wintypes.DWORD),
        ("ServerIndex", wintypes.DWORD),
        ("Type", ctypes.c_int),
        ("Property", DNS_SERVER_PROPERTY_TYPES),
    ]
#[repr(C)]
pub struct DNS_SERVER_PROPERTY_TYPES {
    pub DohSettings: *mut core::ffi::c_void,
    pub DotSettings: *mut core::ffi::c_void,
}

#[repr(C)]
pub struct DNS_SERVER_PROPERTY {
    pub Version: u32,
    pub ServerIndex: u32,
    pub Type: i32,
    pub Property: DNS_SERVER_PROPERTY_TYPES,
}
import "golang.org/x/sys/windows"

type DNS_SERVER_PROPERTY_TYPES struct {
	DohSettings uintptr
	DotSettings uintptr
}

type DNS_SERVER_PROPERTY struct {
	Version uint32
	ServerIndex uint32
	Type int32
	Property DNS_SERVER_PROPERTY_TYPES
}
type
  DNS_SERVER_PROPERTY_TYPES = record
    DohSettings: Pointer;
    DotSettings: Pointer;
  end;

  DNS_SERVER_PROPERTY = record
    Version: DWORD;
    ServerIndex: DWORD;
    Type: Integer;
    Property: DNS_SERVER_PROPERTY_TYPES;
  end;
const DNS_SERVER_PROPERTY_TYPES = extern struct {
    DohSettings: ?*anyopaque,
    DotSettings: ?*anyopaque,
};

const DNS_SERVER_PROPERTY = extern struct {
    Version: u32,
    ServerIndex: u32,
    Type: i32,
    Property: DNS_SERVER_PROPERTY_TYPES,
};
type
  DNS_SERVER_PROPERTY_TYPES {.bycopy.} = object
    DohSettings: pointer
    DotSettings: pointer

  DNS_SERVER_PROPERTY {.bycopy.} = object
    Version: uint32
    ServerIndex: uint32
    Type: int32
    Property: DNS_SERVER_PROPERTY_TYPES
struct DNS_SERVER_PROPERTY_TYPES
{
    void* DohSettings;
    void* DotSettings;
}

struct DNS_SERVER_PROPERTY
{
    uint Version;
    uint ServerIndex;
    int Type;
    DNS_SERVER_PROPERTY_TYPES Property;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; DNS_SERVER_PROPERTY サイズ: 16 バイト(x86)
dim st, 4    ; 4byte整数×4(構造体サイズ 16 / 4 切り上げ)
; Version : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; ServerIndex : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; Type : DNS_SERVER_PROPERTY_TYPE (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; Property : DNS_SERVER_PROPERTY_TYPES (+12, 4byte)  varptr(st)+12 を基点に操作(4byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; DNS_SERVER_PROPERTY サイズ: 24 バイト(x64)
dim st, 6    ; 4byte整数×6(構造体サイズ 24 / 4 切り上げ)
; Version : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; ServerIndex : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; Type : DNS_SERVER_PROPERTY_TYPE (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; Property : DNS_SERVER_PROPERTY_TYPES (+16, 8byte)  varptr(st)+16 を基点に操作(8byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global DNS_SERVER_PROPERTY
    #field int Version
    #field int ServerIndex
    #field int Type
    #field byte Property 8
#endstruct

stdim st, DNS_SERVER_PROPERTY        ; NSTRUCT 変数を確保
st->Version = 100
mes "Version=" + st->Version
; ※union フィールドは byte 列で確保(NSTRUCT は union 非対応)。必要に応じ手動でアクセス。