Win32 API 日本語リファレンス
ホームNetworking.WinSock › INET_PORT_RESERVATION_INSTANCE

INET_PORT_RESERVATION_INSTANCE

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

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

フィールド

フィールドサイズx64x86説明
ReservationINET_PORT_RANGE4+0+0割り当てられたポート範囲を表すINET_PORT_RANGE構造体。
TokenINET_PORT_RESERVATION_TOKEN8+8+8この予約インスタンスを識別するINET_PORT_RESERVATION_TOKEN。

各言語での定義

#include <windows.h>

// INET_PORT_RANGE  (x64 4 / x86 4 バイト)
typedef struct INET_PORT_RANGE {
    WORD StartPort;
    WORD NumberOfPorts;
} INET_PORT_RANGE;

// INET_PORT_RESERVATION_TOKEN  (x64 8 / x86 8 バイト)
typedef struct INET_PORT_RESERVATION_TOKEN {
    ULONGLONG Token;
} INET_PORT_RESERVATION_TOKEN;

// INET_PORT_RESERVATION_INSTANCE  (x64 16 / x86 16 バイト)
typedef struct INET_PORT_RESERVATION_INSTANCE {
    INET_PORT_RANGE Reservation;
    INET_PORT_RESERVATION_TOKEN Token;
} INET_PORT_RESERVATION_INSTANCE;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct INET_PORT_RANGE
{
    public ushort StartPort;
    public ushort NumberOfPorts;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct INET_PORT_RESERVATION_TOKEN
{
    public ulong Token;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct INET_PORT_RESERVATION_INSTANCE
{
    public INET_PORT_RANGE Reservation;
    public INET_PORT_RESERVATION_TOKEN Token;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure INET_PORT_RANGE
    Public StartPort As UShort
    Public NumberOfPorts As UShort
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure INET_PORT_RESERVATION_TOKEN
    Public Token As ULong
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure INET_PORT_RESERVATION_INSTANCE
    Public Reservation As INET_PORT_RANGE
    Public Token As INET_PORT_RESERVATION_TOKEN
End Structure
import ctypes
from ctypes import wintypes

class INET_PORT_RANGE(ctypes.Structure):
    _fields_ = [
        ("StartPort", ctypes.c_ushort),
        ("NumberOfPorts", ctypes.c_ushort),
    ]

class INET_PORT_RESERVATION_TOKEN(ctypes.Structure):
    _fields_ = [
        ("Token", ctypes.c_ulonglong),
    ]

class INET_PORT_RESERVATION_INSTANCE(ctypes.Structure):
    _fields_ = [
        ("Reservation", INET_PORT_RANGE),
        ("Token", INET_PORT_RESERVATION_TOKEN),
    ]
#[repr(C)]
pub struct INET_PORT_RANGE {
    pub StartPort: u16,
    pub NumberOfPorts: u16,
}

#[repr(C)]
pub struct INET_PORT_RESERVATION_TOKEN {
    pub Token: u64,
}

#[repr(C)]
pub struct INET_PORT_RESERVATION_INSTANCE {
    pub Reservation: INET_PORT_RANGE,
    pub Token: INET_PORT_RESERVATION_TOKEN,
}
import "golang.org/x/sys/windows"

type INET_PORT_RANGE struct {
	StartPort uint16
	NumberOfPorts uint16
}

type INET_PORT_RESERVATION_TOKEN struct {
	Token uint64
}

type INET_PORT_RESERVATION_INSTANCE struct {
	Reservation INET_PORT_RANGE
	Token INET_PORT_RESERVATION_TOKEN
}
type
  INET_PORT_RANGE = record
    StartPort: Word;
    NumberOfPorts: Word;
  end;

  INET_PORT_RESERVATION_TOKEN = record
    Token: UInt64;
  end;

  INET_PORT_RESERVATION_INSTANCE = record
    Reservation: INET_PORT_RANGE;
    Token: INET_PORT_RESERVATION_TOKEN;
  end;
const INET_PORT_RANGE = extern struct {
    StartPort: u16,
    NumberOfPorts: u16,
};

const INET_PORT_RESERVATION_TOKEN = extern struct {
    Token: u64,
};

const INET_PORT_RESERVATION_INSTANCE = extern struct {
    Reservation: INET_PORT_RANGE,
    Token: INET_PORT_RESERVATION_TOKEN,
};
type
  INET_PORT_RANGE {.bycopy.} = object
    StartPort: uint16
    NumberOfPorts: uint16

  INET_PORT_RESERVATION_TOKEN {.bycopy.} = object
    Token: uint64

  INET_PORT_RESERVATION_INSTANCE {.bycopy.} = object
    Reservation: INET_PORT_RANGE
    Token: INET_PORT_RESERVATION_TOKEN
struct INET_PORT_RANGE
{
    ushort StartPort;
    ushort NumberOfPorts;
}

struct INET_PORT_RESERVATION_TOKEN
{
    ulong Token;
}

struct INET_PORT_RESERVATION_INSTANCE
{
    INET_PORT_RANGE Reservation;
    INET_PORT_RESERVATION_TOKEN Token;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; INET_PORT_RESERVATION_INSTANCE サイズ: 16 バイト(x64)
dim st, 4    ; 4byte整数×4(構造体サイズ 16 / 4 切り上げ)
; Reservation : INET_PORT_RANGE (+0, 4byte)  varptr(st)+0 を基点に操作(4byte:入れ子/配列)
; Token : INET_PORT_RESERVATION_TOKEN (+8, 8byte)  varptr(st)+8 を基点に操作(8byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global INET_PORT_RANGE
    #field short StartPort
    #field short NumberOfPorts
#endstruct

#defstruct global INET_PORT_RESERVATION_TOKEN
    #field int64 Token
#endstruct

#defstruct global INET_PORT_RESERVATION_INSTANCE
    #field INET_PORT_RANGE Reservation
    #field INET_PORT_RESERVATION_TOKEN Token
#endstruct

stdim st, INET_PORT_RESERVATION_INSTANCE        ; NSTRUCT 変数を確保