NRESARRAY
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| cItems | DWORD | 4 | +0 | +0 | nr配列に含まれるネットワークリソースの数。 |
| nr | NETRESOURCEA | 48/32 | +8 | +4 | NETRESOURCEA構造体の可変長配列。ネットワークリソース情報を保持する。 |
各言語での定義
#include <windows.h>
// NETRESOURCEA (x64 48 / x86 32 バイト)
typedef struct NETRESOURCEA {
NET_RESOURCE_SCOPE dwScope;
NET_RESOURCE_TYPE dwType;
DWORD dwDisplayType;
DWORD dwUsage;
LPSTR lpLocalName;
LPSTR lpRemoteName;
LPSTR lpComment;
LPSTR lpProvider;
} NETRESOURCEA;
// NRESARRAY (x64 56 / x86 36 バイト)
typedef struct NRESARRAY {
DWORD cItems;
NETRESOURCEA nr[1];
} NRESARRAY;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct NETRESOURCEA
{
public uint dwScope;
public uint dwType;
public uint dwDisplayType;
public uint dwUsage;
public IntPtr lpLocalName;
public IntPtr lpRemoteName;
public IntPtr lpComment;
public IntPtr lpProvider;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct NRESARRAY
{
public uint cItems;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public NETRESOURCEA[] nr;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure NETRESOURCEA
Public dwScope As UInteger
Public dwType As UInteger
Public dwDisplayType As UInteger
Public dwUsage As UInteger
Public lpLocalName As IntPtr
Public lpRemoteName As IntPtr
Public lpComment As IntPtr
Public lpProvider As IntPtr
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure NRESARRAY
Public cItems As UInteger
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public nr() As NETRESOURCEA
End Structureimport ctypes
from ctypes import wintypes
class NETRESOURCEA(ctypes.Structure):
_fields_ = [
("dwScope", wintypes.DWORD),
("dwType", wintypes.DWORD),
("dwDisplayType", wintypes.DWORD),
("dwUsage", wintypes.DWORD),
("lpLocalName", ctypes.c_void_p),
("lpRemoteName", ctypes.c_void_p),
("lpComment", ctypes.c_void_p),
("lpProvider", ctypes.c_void_p),
]
class NRESARRAY(ctypes.Structure):
_fields_ = [
("cItems", wintypes.DWORD),
("nr", NETRESOURCEA * 1),
]#[repr(C)]
pub struct NETRESOURCEA {
pub dwScope: u32,
pub dwType: u32,
pub dwDisplayType: u32,
pub dwUsage: u32,
pub lpLocalName: *mut core::ffi::c_void,
pub lpRemoteName: *mut core::ffi::c_void,
pub lpComment: *mut core::ffi::c_void,
pub lpProvider: *mut core::ffi::c_void,
}
#[repr(C)]
pub struct NRESARRAY {
pub cItems: u32,
pub nr: [NETRESOURCEA; 1],
}import "golang.org/x/sys/windows"
type NETRESOURCEA struct {
dwScope uint32
dwType uint32
dwDisplayType uint32
dwUsage uint32
lpLocalName uintptr
lpRemoteName uintptr
lpComment uintptr
lpProvider uintptr
}
type NRESARRAY struct {
cItems uint32
nr [1]NETRESOURCEA
}type
NETRESOURCEA = record
dwScope: DWORD;
dwType: DWORD;
dwDisplayType: DWORD;
dwUsage: DWORD;
lpLocalName: Pointer;
lpRemoteName: Pointer;
lpComment: Pointer;
lpProvider: Pointer;
end;
NRESARRAY = record
cItems: DWORD;
nr: array[0..0] of NETRESOURCEA;
end;const NETRESOURCEA = extern struct {
dwScope: u32,
dwType: u32,
dwDisplayType: u32,
dwUsage: u32,
lpLocalName: ?*anyopaque,
lpRemoteName: ?*anyopaque,
lpComment: ?*anyopaque,
lpProvider: ?*anyopaque,
};
const NRESARRAY = extern struct {
cItems: u32,
nr: [1]NETRESOURCEA,
};type
NETRESOURCEA {.bycopy.} = object
dwScope: uint32
dwType: uint32
dwDisplayType: uint32
dwUsage: uint32
lpLocalName: pointer
lpRemoteName: pointer
lpComment: pointer
lpProvider: pointer
NRESARRAY {.bycopy.} = object
cItems: uint32
nr: array[1, NETRESOURCEA]struct NETRESOURCEA
{
uint dwScope;
uint dwType;
uint dwDisplayType;
uint dwUsage;
void* lpLocalName;
void* lpRemoteName;
void* lpComment;
void* lpProvider;
}
struct NRESARRAY
{
uint cItems;
NETRESOURCEA[1] nr;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; NRESARRAY サイズ: 36 バイト(x86)
dim st, 9 ; 4byte整数×9(構造体サイズ 36 / 4 切り上げ)
; cItems : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; nr : NETRESOURCEA (+4, 32byte) varptr(st)+4 を基点に操作(32byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; NRESARRAY サイズ: 56 バイト(x64)
dim st, 14 ; 4byte整数×14(構造体サイズ 56 / 4 切り上げ)
; cItems : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; nr : NETRESOURCEA (+8, 48byte) varptr(st)+8 を基点に操作(48byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global NETRESOURCEA
#field int dwScope
#field int dwType
#field int dwDisplayType
#field int dwUsage
#field intptr lpLocalName
#field intptr lpRemoteName
#field intptr lpComment
#field intptr lpProvider
#endstruct
#defstruct global NRESARRAY
#field int cItems
#field NETRESOURCEA nr 1
#endstruct
stdim st, NRESARRAY ; NSTRUCT 変数を確保
st->cItems = 100
mes "cItems=" + st->cItems