ホーム › NetworkManagement.Dns › DNS_SRV_DATAW
DNS_SRV_DATAW
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| pNameTarget | LPWSTR | 8/4 | +0 | +0 | サービスを提供するホストの名前を表すワイド文字列ポインタ。 |
| wPriority | WORD | 2 | +8 | +4 | 対象ホストの優先度を示す。値が小さいほど優先される。 |
| wWeight | WORD | 2 | +10 | +6 | 同優先度内での選択重みを示す。値が大きいほど選ばれやすい。 |
| wPort | WORD | 2 | +12 | +8 | サービスが待ち受けるポート番号を示す。 |
| Pad | WORD | 2 | +14 | +10 | アラインメント調整用のパディング。値は通常0。 |
各言語での定義
#include <windows.h>
// DNS_SRV_DATAW (x64 16 / x86 12 バイト)
typedef struct DNS_SRV_DATAW {
LPWSTR pNameTarget;
WORD wPriority;
WORD wWeight;
WORD wPort;
WORD Pad;
} DNS_SRV_DATAW;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DNS_SRV_DATAW
{
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_DATAW
Public pNameTarget As IntPtr
Public wPriority As UShort
Public wWeight As UShort
Public wPort As UShort
Public Pad As UShort
End Structureimport ctypes
from ctypes import wintypes
class DNS_SRV_DATAW(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_DATAW {
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_DATAW struct {
pNameTarget uintptr
wPriority uint16
wWeight uint16
wPort uint16
Pad uint16
}type
DNS_SRV_DATAW = record
pNameTarget: Pointer;
wPriority: Word;
wWeight: Word;
wPort: Word;
Pad: Word;
end;const DNS_SRV_DATAW = extern struct {
pNameTarget: ?*anyopaque,
wPriority: u16,
wWeight: u16,
wPort: u16,
Pad: u16,
};type
DNS_SRV_DATAW {.bycopy.} = object
pNameTarget: pointer
wPriority: uint16
wWeight: uint16
wPort: uint16
Pad: uint16struct DNS_SRV_DATAW
{
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_DATAW サイズ: 12 バイト(x86)
dim st, 3 ; 4byte整数×3(構造体サイズ 12 / 4 切り上げ)
; pNameTarget : LPWSTR (+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_DATAW サイズ: 16 バイト(x64)
dim st, 4 ; 4byte整数×4(構造体サイズ 16 / 4 切り上げ)
; pNameTarget : LPWSTR (+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_DATAW
#field intptr pNameTarget
#field short wPriority
#field short wWeight
#field short wPort
#field short Pad
#endstruct
stdim st, DNS_SRV_DATAW ; NSTRUCT 変数を確保
st->wPriority = 100
mes "wPriority=" + st->wPriority