ホーム › NetworkManagement.Dns › DNS_SERVICE_INSTANCE
DNS_SERVICE_INSTANCE
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| pszInstanceName | LPWSTR | 8/4 | +0 | +0 | DNS-SDサービスインスタンスの完全名を表すワイド文字列ポインタ。 |
| pszHostName | LPWSTR | 8/4 | +8 | +4 | サービスを提供するホスト名を表すワイド文字列ポインタ。 |
| ip4Address | DWORD* | 8/4 | +16 | +8 | サービスのIPv4アドレスを指すポインタ。NULL可。 |
| ip6Address | IP6_ADDRESS* | 8/4 | +24 | +12 | サービスのIPv6アドレスを指すポインタ。NULL可。 |
| wPort | WORD | 2 | +32 | +16 | サービスが待ち受けるポート番号を示す。 |
| wPriority | WORD | 2 | +34 | +18 | サービスの優先度を示す。値が小さいほど優先される。 |
| wWeight | WORD | 2 | +36 | +20 | 同優先度内での選択重みを示す。 |
| dwPropertyCount | DWORD | 4 | +40 | +24 | keys/valuesに格納されたTXTプロパティの個数を示す。 |
| keys | LPWSTR* | 8/4 | +48 | +28 | TXTプロパティのキー文字列配列を指すポインタ。 |
| values | LPWSTR* | 8/4 | +56 | +32 | TXTプロパティの値文字列配列を指すポインタ。keysと対応する。 |
| dwInterfaceIndex | DWORD | 4 | +64 | +36 | サービスが存在するネットワークインターフェースのインデックスを示す。 |
各言語での定義
#include <windows.h>
// DNS_SERVICE_INSTANCE (x64 72 / x86 40 バイト)
typedef struct DNS_SERVICE_INSTANCE {
LPWSTR pszInstanceName;
LPWSTR pszHostName;
DWORD* ip4Address;
IP6_ADDRESS* ip6Address;
WORD wPort;
WORD wPriority;
WORD wWeight;
DWORD dwPropertyCount;
LPWSTR* keys;
LPWSTR* values;
DWORD dwInterfaceIndex;
} DNS_SERVICE_INSTANCE;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DNS_SERVICE_INSTANCE
{
public IntPtr pszInstanceName;
public IntPtr pszHostName;
public IntPtr ip4Address;
public IntPtr ip6Address;
public ushort wPort;
public ushort wPriority;
public ushort wWeight;
public uint dwPropertyCount;
public IntPtr keys;
public IntPtr values;
public uint dwInterfaceIndex;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DNS_SERVICE_INSTANCE
Public pszInstanceName As IntPtr
Public pszHostName As IntPtr
Public ip4Address As IntPtr
Public ip6Address As IntPtr
Public wPort As UShort
Public wPriority As UShort
Public wWeight As UShort
Public dwPropertyCount As UInteger
Public keys As IntPtr
Public values As IntPtr
Public dwInterfaceIndex As UInteger
End Structureimport ctypes
from ctypes import wintypes
class DNS_SERVICE_INSTANCE(ctypes.Structure):
_fields_ = [
("pszInstanceName", ctypes.c_void_p),
("pszHostName", ctypes.c_void_p),
("ip4Address", ctypes.c_void_p),
("ip6Address", ctypes.c_void_p),
("wPort", ctypes.c_ushort),
("wPriority", ctypes.c_ushort),
("wWeight", ctypes.c_ushort),
("dwPropertyCount", wintypes.DWORD),
("keys", ctypes.c_void_p),
("values", ctypes.c_void_p),
("dwInterfaceIndex", wintypes.DWORD),
]#[repr(C)]
pub struct DNS_SERVICE_INSTANCE {
pub pszInstanceName: *mut core::ffi::c_void,
pub pszHostName: *mut core::ffi::c_void,
pub ip4Address: *mut core::ffi::c_void,
pub ip6Address: *mut core::ffi::c_void,
pub wPort: u16,
pub wPriority: u16,
pub wWeight: u16,
pub dwPropertyCount: u32,
pub keys: *mut core::ffi::c_void,
pub values: *mut core::ffi::c_void,
pub dwInterfaceIndex: u32,
}import "golang.org/x/sys/windows"
type DNS_SERVICE_INSTANCE struct {
pszInstanceName uintptr
pszHostName uintptr
ip4Address uintptr
ip6Address uintptr
wPort uint16
wPriority uint16
wWeight uint16
dwPropertyCount uint32
keys uintptr
values uintptr
dwInterfaceIndex uint32
}type
DNS_SERVICE_INSTANCE = record
pszInstanceName: Pointer;
pszHostName: Pointer;
ip4Address: Pointer;
ip6Address: Pointer;
wPort: Word;
wPriority: Word;
wWeight: Word;
dwPropertyCount: DWORD;
keys: Pointer;
values: Pointer;
dwInterfaceIndex: DWORD;
end;const DNS_SERVICE_INSTANCE = extern struct {
pszInstanceName: ?*anyopaque,
pszHostName: ?*anyopaque,
ip4Address: ?*anyopaque,
ip6Address: ?*anyopaque,
wPort: u16,
wPriority: u16,
wWeight: u16,
dwPropertyCount: u32,
keys: ?*anyopaque,
values: ?*anyopaque,
dwInterfaceIndex: u32,
};type
DNS_SERVICE_INSTANCE {.bycopy.} = object
pszInstanceName: pointer
pszHostName: pointer
ip4Address: pointer
ip6Address: pointer
wPort: uint16
wPriority: uint16
wWeight: uint16
dwPropertyCount: uint32
keys: pointer
values: pointer
dwInterfaceIndex: uint32struct DNS_SERVICE_INSTANCE
{
void* pszInstanceName;
void* pszHostName;
void* ip4Address;
void* ip6Address;
ushort wPort;
ushort wPriority;
ushort wWeight;
uint dwPropertyCount;
void* keys;
void* values;
uint dwInterfaceIndex;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; DNS_SERVICE_INSTANCE サイズ: 40 バイト(x86)
dim st, 10 ; 4byte整数×10(構造体サイズ 40 / 4 切り上げ)
; pszInstanceName : LPWSTR (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; pszHostName : LPWSTR (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; ip4Address : DWORD* (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; ip6Address : IP6_ADDRESS* (+12, 4byte) varptr(st)+12 を基点に操作(4byte:入れ子/配列)
; wPort : WORD (+16, 2byte) wpoke st,16,値 / 値 = wpeek(st,16)
; wPriority : WORD (+18, 2byte) wpoke st,18,値 / 値 = wpeek(st,18)
; wWeight : WORD (+20, 2byte) wpoke st,20,値 / 値 = wpeek(st,20)
; dwPropertyCount : DWORD (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; keys : LPWSTR* (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; values : LPWSTR* (+32, 4byte) st.8 = 値 / 値 = st.8 (lpoke/lpeek も可)
; dwInterfaceIndex : DWORD (+36, 4byte) st.9 = 値 / 値 = st.9 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; DNS_SERVICE_INSTANCE サイズ: 72 バイト(x64)
dim st, 18 ; 4byte整数×18(構造体サイズ 72 / 4 切り上げ)
; pszInstanceName : LPWSTR (+0, 8byte) qpoke st,0,値 / qpeek(st,0) ※IronHSPのみ。3.7/3.8は lpoke st,0,下位 : lpoke st,4,上位
; pszHostName : LPWSTR (+8, 8byte) qpoke st,8,値 / qpeek(st,8) ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; ip4Address : DWORD* (+16, 8byte) qpoke st,16,値 / qpeek(st,16) ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; ip6Address : IP6_ADDRESS* (+24, 8byte) varptr(st)+24 を基点に操作(8byte:入れ子/配列)
; wPort : WORD (+32, 2byte) wpoke st,32,値 / 値 = wpeek(st,32)
; wPriority : WORD (+34, 2byte) wpoke st,34,値 / 値 = wpeek(st,34)
; wWeight : WORD (+36, 2byte) wpoke st,36,値 / 値 = wpeek(st,36)
; dwPropertyCount : DWORD (+40, 4byte) st.10 = 値 / 値 = st.10 (lpoke/lpeek も可)
; keys : LPWSTR* (+48, 8byte) qpoke st,48,値 / qpeek(st,48) ※IronHSPのみ。3.7/3.8は lpoke st,48,下位 : lpoke st,52,上位
; values : LPWSTR* (+56, 8byte) qpoke st,56,値 / qpeek(st,56) ※IronHSPのみ。3.7/3.8は lpoke st,56,下位 : lpoke st,60,上位
; dwInterfaceIndex : DWORD (+64, 4byte) st.16 = 値 / 値 = st.16 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global DNS_SERVICE_INSTANCE
#field intptr pszInstanceName
#field intptr pszHostName
#field intptr ip4Address
#field intptr ip6Address
#field short wPort
#field short wPriority
#field short wWeight
#field int dwPropertyCount
#field intptr keys
#field intptr values
#field int dwInterfaceIndex
#endstruct
stdim st, DNS_SERVICE_INSTANCE ; NSTRUCT 変数を確保
st->wPort = 100
mes "wPort=" + st->wPort