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

DNS_SRV_DATAA

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

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

フィールド

フィールドサイズx64x86説明
pNameTargetLPSTR8/4+0+0サービスを提供するホストの名前を表すANSI文字列ポインタ。
wPriorityWORD2+8+4対象ホストの優先度を示す。値が小さいほど優先される。
wWeightWORD2+10+6同優先度内での選択重みを示す。値が大きいほど選ばれやすい。
wPortWORD2+12+8サービスが待ち受けるポート番号を示す。
PadWORD2+14+10アラインメント調整用のパディング。値は通常0。

各言語での定義

#include <windows.h>

// DNS_SRV_DATAA  (x64 16 / x86 12 バイト)
typedef struct DNS_SRV_DATAA {
    LPSTR pNameTarget;
    WORD wPriority;
    WORD wWeight;
    WORD wPort;
    WORD Pad;
} DNS_SRV_DATAA;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DNS_SRV_DATAA
{
    public IntPtr pNameTarget;
    public ushort wPriority;
    public ushort wWeight;
    public ushort wPort;
    public ushort Pad;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DNS_SRV_DATAA
    Public pNameTarget As IntPtr
    Public wPriority As UShort
    Public wWeight As UShort
    Public wPort As UShort
    Public Pad As UShort
End Structure
import ctypes
from ctypes import wintypes

class DNS_SRV_DATAA(ctypes.Structure):
    _fields_ = [
        ("pNameTarget", ctypes.c_void_p),
        ("wPriority", ctypes.c_ushort),
        ("wWeight", ctypes.c_ushort),
        ("wPort", ctypes.c_ushort),
        ("Pad", ctypes.c_ushort),
    ]
#[repr(C)]
pub struct DNS_SRV_DATAA {
    pub pNameTarget: *mut core::ffi::c_void,
    pub wPriority: u16,
    pub wWeight: u16,
    pub wPort: u16,
    pub Pad: u16,
}
import "golang.org/x/sys/windows"

type DNS_SRV_DATAA struct {
	pNameTarget uintptr
	wPriority uint16
	wWeight uint16
	wPort uint16
	Pad uint16
}
type
  DNS_SRV_DATAA = record
    pNameTarget: Pointer;
    wPriority: Word;
    wWeight: Word;
    wPort: Word;
    Pad: Word;
  end;
const DNS_SRV_DATAA = extern struct {
    pNameTarget: ?*anyopaque,
    wPriority: u16,
    wWeight: u16,
    wPort: u16,
    Pad: u16,
};
type
  DNS_SRV_DATAA {.bycopy.} = object
    pNameTarget: pointer
    wPriority: uint16
    wWeight: uint16
    wPort: uint16
    Pad: uint16
struct DNS_SRV_DATAA
{
    void* pNameTarget;
    ushort wPriority;
    ushort wWeight;
    ushort wPort;
    ushort Pad;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; DNS_SRV_DATAA サイズ: 12 バイト(x86)
dim st, 3    ; 4byte整数×3(構造体サイズ 12 / 4 切り上げ)
; pNameTarget : LPSTR (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; wPriority : WORD (+4, 2byte)  wpoke st,4,値  /  値 = wpeek(st,4)
; wWeight : WORD (+6, 2byte)  wpoke st,6,値  /  値 = wpeek(st,6)
; wPort : WORD (+8, 2byte)  wpoke st,8,値  /  値 = wpeek(st,8)
; Pad : WORD (+10, 2byte)  wpoke st,10,値  /  値 = wpeek(st,10)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; DNS_SRV_DATAA サイズ: 16 バイト(x64)
dim st, 4    ; 4byte整数×4(構造体サイズ 16 / 4 切り上げ)
; pNameTarget : LPSTR (+0, 8byte)  qpoke st,0,値 / qpeek(st,0)  ※IronHSPのみ。3.7/3.8は lpoke st,0,下位 : lpoke st,4,上位
; wPriority : WORD (+8, 2byte)  wpoke st,8,値  /  値 = wpeek(st,8)
; wWeight : WORD (+10, 2byte)  wpoke st,10,値  /  値 = wpeek(st,10)
; wPort : WORD (+12, 2byte)  wpoke st,12,値  /  値 = wpeek(st,12)
; Pad : WORD (+14, 2byte)  wpoke st,14,値  /  値 = wpeek(st,14)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global DNS_SRV_DATAA
    #field intptr pNameTarget
    #field short wPriority
    #field short wWeight
    #field short wPort
    #field short Pad
#endstruct

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