ホーム › NetworkManagement.QoS › IN_ADDR_IPV4
IN_ADDR_IPV4
共用体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| Addr | DWORD | 4 | +0 | +0 | IPv4アドレスを32ビット整数として保持するメンバー。 |
| AddrBytes | BYTE | 4 | +0 | +0 | 同一アドレスをバイト配列として参照するメンバー(共用体)。 |
各言語での定義
#include <windows.h>
// IN_ADDR_IPV4 (x64 4 / x86 4 バイト)
typedef struct IN_ADDR_IPV4 {
DWORD Addr;
BYTE AddrBytes[4];
} IN_ADDR_IPV4;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct IN_ADDR_IPV4
{
public uint Addr;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public byte[] AddrBytes;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure IN_ADDR_IPV4
Public Addr As UInteger
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=4)> Public AddrBytes() As Byte
End Structureimport ctypes
from ctypes import wintypes
class IN_ADDR_IPV4(ctypes.Structure):
_fields_ = [
("Addr", wintypes.DWORD),
("AddrBytes", ctypes.c_ubyte * 4),
]#[repr(C)]
pub struct IN_ADDR_IPV4 {
pub Addr: u32,
pub AddrBytes: [u8; 4],
}import "golang.org/x/sys/windows"
type IN_ADDR_IPV4 struct {
Addr uint32
AddrBytes [4]byte
}type
IN_ADDR_IPV4 = record
Addr: DWORD;
AddrBytes: array[0..3] of Byte;
end;const IN_ADDR_IPV4 = extern struct {
Addr: u32,
AddrBytes: [4]u8,
};type
IN_ADDR_IPV4 {.bycopy.} = object
Addr: uint32
AddrBytes: array[4, uint8]struct IN_ADDR_IPV4
{
uint Addr;
ubyte[4] AddrBytes;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; IN_ADDR_IPV4 サイズ: 4 バイト(x64)
dim st, 1 ; 4byte整数×1(構造体サイズ 4 / 4 切り上げ)
; Addr : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; AddrBytes : BYTE (+0, 4byte) varptr(st)+0 を基点に操作(4byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global IN_ADDR_IPV4
#field int Addr
#field byte AddrBytes 4
#endstruct
stdim st, IN_ADDR_IPV4 ; NSTRUCT 変数を確保
st->Addr = 100
mes "Addr=" + st->Addr