Win32 API 日本語リファレンス
ホームStorage.IscsiDisc › ISCSI_TARGET_PORTAL_GROUPW

ISCSI_TARGET_PORTAL_GROUPW

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

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

フィールド

フィールドサイズx64x86説明
CountDWORD4+0+0Portals配列に格納されるポータル数。
PortalsISCSI_TARGET_PORTALW1026+4+4ポータルグループを構成するISCSI_TARGET_PORTALWの可変長配列(先頭1要素を宣言)。

各言語での定義

#include <windows.h>

// ISCSI_TARGET_PORTALW  (x64 1026 / x86 1026 バイト)
typedef struct ISCSI_TARGET_PORTALW {
    WCHAR SymbolicName[256];
    WCHAR Address[256];
    WORD Socket;
} ISCSI_TARGET_PORTALW;

// ISCSI_TARGET_PORTAL_GROUPW  (x64 1032 / x86 1032 バイト)
typedef struct ISCSI_TARGET_PORTAL_GROUPW {
    DWORD Count;
    ISCSI_TARGET_PORTALW Portals[1];
} ISCSI_TARGET_PORTAL_GROUPW;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct ISCSI_TARGET_PORTALW
{
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] public string SymbolicName;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] public string Address;
    public ushort Socket;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct ISCSI_TARGET_PORTAL_GROUPW
{
    public uint Count;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public ISCSI_TARGET_PORTALW[] Portals;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure ISCSI_TARGET_PORTALW
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> Public SymbolicName As String
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> Public Address As String
    Public Socket As UShort
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure ISCSI_TARGET_PORTAL_GROUPW
    Public Count As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public Portals() As ISCSI_TARGET_PORTALW
End Structure
import ctypes
from ctypes import wintypes

class ISCSI_TARGET_PORTALW(ctypes.Structure):
    _fields_ = [
        ("SymbolicName", ctypes.c_wchar * 256),
        ("Address", ctypes.c_wchar * 256),
        ("Socket", ctypes.c_ushort),
    ]

class ISCSI_TARGET_PORTAL_GROUPW(ctypes.Structure):
    _fields_ = [
        ("Count", wintypes.DWORD),
        ("Portals", ISCSI_TARGET_PORTALW * 1),
    ]
#[repr(C)]
pub struct ISCSI_TARGET_PORTALW {
    pub SymbolicName: [u16; 256],
    pub Address: [u16; 256],
    pub Socket: u16,
}

#[repr(C)]
pub struct ISCSI_TARGET_PORTAL_GROUPW {
    pub Count: u32,
    pub Portals: [ISCSI_TARGET_PORTALW; 1],
}
import "golang.org/x/sys/windows"

type ISCSI_TARGET_PORTALW struct {
	SymbolicName [256]uint16
	Address [256]uint16
	Socket uint16
}

type ISCSI_TARGET_PORTAL_GROUPW struct {
	Count uint32
	Portals [1]ISCSI_TARGET_PORTALW
}
type
  ISCSI_TARGET_PORTALW = record
    SymbolicName: array[0..255] of WideChar;
    Address: array[0..255] of WideChar;
    Socket: Word;
  end;

  ISCSI_TARGET_PORTAL_GROUPW = record
    Count: DWORD;
    Portals: array[0..0] of ISCSI_TARGET_PORTALW;
  end;
const ISCSI_TARGET_PORTALW = extern struct {
    SymbolicName: [256]u16,
    Address: [256]u16,
    Socket: u16,
};

const ISCSI_TARGET_PORTAL_GROUPW = extern struct {
    Count: u32,
    Portals: [1]ISCSI_TARGET_PORTALW,
};
type
  ISCSI_TARGET_PORTALW {.bycopy.} = object
    SymbolicName: array[256, uint16]
    Address: array[256, uint16]
    Socket: uint16

  ISCSI_TARGET_PORTAL_GROUPW {.bycopy.} = object
    Count: uint32
    Portals: array[1, ISCSI_TARGET_PORTALW]
struct ISCSI_TARGET_PORTALW
{
    wchar[256] SymbolicName;
    wchar[256] Address;
    ushort Socket;
}

struct ISCSI_TARGET_PORTAL_GROUPW
{
    uint Count;
    ISCSI_TARGET_PORTALW[1] Portals;
}

HSP用 定義

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

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

#defstruct global ISCSI_TARGET_PORTAL_GROUPW
    #field int Count
    #field ISCSI_TARGET_PORTALW Portals 1
#endstruct

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