ホーム › Networking.WinSock › NETRESOURCE2W
NETRESOURCE2W
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| dwScope | DWORD | 4 | +0 | +0 | リソースの列挙範囲(接続済み/全体等)を示す。 |
| dwType | DWORD | 4 | +4 | +4 | リソースの種別(ディスク/プリンタ等)を示す。 |
| dwUsage | DWORD | 4 | +8 | +8 | リソースの用途(接続可能/コンテナ等)を示すフラグ。 |
| dwDisplayType | DWORD | 4 | +12 | +12 | シェルでの表示種別を示す。 |
| lpLocalName | LPWSTR | 8/4 | +16 | +16 | リソースのローカル名(デバイス名)を表すUnicode文字列へのポインタ。 |
| lpRemoteName | LPWSTR | 8/4 | +24 | +20 | リソースのリモート(ネットワーク)名を表すUnicode文字列へのポインタ。 |
| lpComment | LPWSTR | 8/4 | +32 | +24 | リソースに関するコメント文字列へのポインタ。 |
| ns_info | NS_INFOA | 16/12 | +40 | +28 | リソースのネームスペース情報を保持するNS_INFOA構造体。 |
| ServiceType | GUID | 16 | +56 | +40 | サービス型を識別するGUID。 |
| dwProtocols | DWORD | 4 | +72 | +56 | lpiProtocols内のプロトコル数を示す。 |
| lpiProtocols | INT* | 8/4 | +80 | +60 | 対応プロトコル番号の配列へのポインタ。 |
各言語での定義
#include <windows.h>
// NS_INFOA (x64 16 / x86 12 バイト)
typedef struct NS_INFOA {
DWORD dwNameSpace;
DWORD dwNameSpaceFlags;
LPSTR lpNameSpace;
} NS_INFOA;
// NETRESOURCE2W (x64 88 / x86 64 バイト)
typedef struct NETRESOURCE2W {
DWORD dwScope;
DWORD dwType;
DWORD dwUsage;
DWORD dwDisplayType;
LPWSTR lpLocalName;
LPWSTR lpRemoteName;
LPWSTR lpComment;
NS_INFOA ns_info;
GUID ServiceType;
DWORD dwProtocols;
INT* lpiProtocols;
} NETRESOURCE2W;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct NS_INFOA
{
public uint dwNameSpace;
public uint dwNameSpaceFlags;
public IntPtr lpNameSpace;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct NETRESOURCE2W
{
public uint dwScope;
public uint dwType;
public uint dwUsage;
public uint dwDisplayType;
public IntPtr lpLocalName;
public IntPtr lpRemoteName;
public IntPtr lpComment;
public NS_INFOA ns_info;
public Guid ServiceType;
public uint dwProtocols;
public IntPtr lpiProtocols;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure NS_INFOA
Public dwNameSpace As UInteger
Public dwNameSpaceFlags As UInteger
Public lpNameSpace As IntPtr
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure NETRESOURCE2W
Public dwScope As UInteger
Public dwType As UInteger
Public dwUsage As UInteger
Public dwDisplayType As UInteger
Public lpLocalName As IntPtr
Public lpRemoteName As IntPtr
Public lpComment As IntPtr
Public ns_info As NS_INFOA
Public ServiceType As Guid
Public dwProtocols As UInteger
Public lpiProtocols As IntPtr
End Structureimport ctypes
from ctypes import wintypes
class NS_INFOA(ctypes.Structure):
_fields_ = [
("dwNameSpace", wintypes.DWORD),
("dwNameSpaceFlags", wintypes.DWORD),
("lpNameSpace", ctypes.c_void_p),
]
class NETRESOURCE2W(ctypes.Structure):
_fields_ = [
("dwScope", wintypes.DWORD),
("dwType", wintypes.DWORD),
("dwUsage", wintypes.DWORD),
("dwDisplayType", wintypes.DWORD),
("lpLocalName", ctypes.c_void_p),
("lpRemoteName", ctypes.c_void_p),
("lpComment", ctypes.c_void_p),
("ns_info", NS_INFOA),
("ServiceType", GUID),
("dwProtocols", wintypes.DWORD),
("lpiProtocols", ctypes.c_void_p),
]#[repr(C)]
pub struct NS_INFOA {
pub dwNameSpace: u32,
pub dwNameSpaceFlags: u32,
pub lpNameSpace: *mut core::ffi::c_void,
}
#[repr(C)]
pub struct NETRESOURCE2W {
pub dwScope: u32,
pub dwType: u32,
pub dwUsage: u32,
pub dwDisplayType: u32,
pub lpLocalName: *mut core::ffi::c_void,
pub lpRemoteName: *mut core::ffi::c_void,
pub lpComment: *mut core::ffi::c_void,
pub ns_info: NS_INFOA,
pub ServiceType: GUID,
pub dwProtocols: u32,
pub lpiProtocols: *mut core::ffi::c_void,
}import "golang.org/x/sys/windows"
type NS_INFOA struct {
dwNameSpace uint32
dwNameSpaceFlags uint32
lpNameSpace uintptr
}
type NETRESOURCE2W struct {
dwScope uint32
dwType uint32
dwUsage uint32
dwDisplayType uint32
lpLocalName uintptr
lpRemoteName uintptr
lpComment uintptr
ns_info NS_INFOA
ServiceType windows.GUID
dwProtocols uint32
lpiProtocols uintptr
}type
NS_INFOA = record
dwNameSpace: DWORD;
dwNameSpaceFlags: DWORD;
lpNameSpace: Pointer;
end;
NETRESOURCE2W = record
dwScope: DWORD;
dwType: DWORD;
dwUsage: DWORD;
dwDisplayType: DWORD;
lpLocalName: Pointer;
lpRemoteName: Pointer;
lpComment: Pointer;
ns_info: NS_INFOA;
ServiceType: TGUID;
dwProtocols: DWORD;
lpiProtocols: Pointer;
end;const NS_INFOA = extern struct {
dwNameSpace: u32,
dwNameSpaceFlags: u32,
lpNameSpace: ?*anyopaque,
};
const NETRESOURCE2W = extern struct {
dwScope: u32,
dwType: u32,
dwUsage: u32,
dwDisplayType: u32,
lpLocalName: ?*anyopaque,
lpRemoteName: ?*anyopaque,
lpComment: ?*anyopaque,
ns_info: NS_INFOA,
ServiceType: GUID,
dwProtocols: u32,
lpiProtocols: ?*anyopaque,
};type
NS_INFOA {.bycopy.} = object
dwNameSpace: uint32
dwNameSpaceFlags: uint32
lpNameSpace: pointer
NETRESOURCE2W {.bycopy.} = object
dwScope: uint32
dwType: uint32
dwUsage: uint32
dwDisplayType: uint32
lpLocalName: pointer
lpRemoteName: pointer
lpComment: pointer
ns_info: NS_INFOA
ServiceType: GUID
dwProtocols: uint32
lpiProtocols: pointerstruct NS_INFOA
{
uint dwNameSpace;
uint dwNameSpaceFlags;
void* lpNameSpace;
}
struct NETRESOURCE2W
{
uint dwScope;
uint dwType;
uint dwUsage;
uint dwDisplayType;
void* lpLocalName;
void* lpRemoteName;
void* lpComment;
NS_INFOA ns_info;
GUID ServiceType;
uint dwProtocols;
void* lpiProtocols;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; NETRESOURCE2W サイズ: 64 バイト(x86)
dim st, 16 ; 4byte整数×16(構造体サイズ 64 / 4 切り上げ)
; dwScope : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; dwType : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; dwUsage : DWORD (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; dwDisplayType : DWORD (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; lpLocalName : LPWSTR (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; lpRemoteName : LPWSTR (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; lpComment : LPWSTR (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; ns_info : NS_INFOA (+28, 12byte) varptr(st)+28 を基点に操作(12byte:入れ子/配列)
; ServiceType : GUID (+40, 16byte) varptr(st)+40 を基点に操作(16byte:入れ子/配列)
; dwProtocols : DWORD (+56, 4byte) st.14 = 値 / 値 = st.14 (lpoke/lpeek も可)
; lpiProtocols : INT* (+60, 4byte) st.15 = 値 / 値 = st.15 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; NETRESOURCE2W サイズ: 88 バイト(x64)
dim st, 22 ; 4byte整数×22(構造体サイズ 88 / 4 切り上げ)
; dwScope : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; dwType : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; dwUsage : DWORD (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; dwDisplayType : DWORD (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; lpLocalName : LPWSTR (+16, 8byte) qpoke st,16,値 / qpeek(st,16) ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; lpRemoteName : LPWSTR (+24, 8byte) qpoke st,24,値 / qpeek(st,24) ※IronHSPのみ。3.7/3.8は lpoke st,24,下位 : lpoke st,28,上位
; lpComment : LPWSTR (+32, 8byte) qpoke st,32,値 / qpeek(st,32) ※IronHSPのみ。3.7/3.8は lpoke st,32,下位 : lpoke st,36,上位
; ns_info : NS_INFOA (+40, 16byte) varptr(st)+40 を基点に操作(16byte:入れ子/配列)
; ServiceType : GUID (+56, 16byte) varptr(st)+56 を基点に操作(16byte:入れ子/配列)
; dwProtocols : DWORD (+72, 4byte) st.18 = 値 / 値 = st.18 (lpoke/lpeek も可)
; lpiProtocols : INT* (+80, 8byte) qpoke st,80,値 / qpeek(st,80) ※IronHSPのみ。3.7/3.8は lpoke st,80,下位 : lpoke st,84,上位
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global NS_INFOA
#field int dwNameSpace
#field int dwNameSpaceFlags
#field intptr lpNameSpace
#endstruct
#defstruct global GUID, pack=1
#field int Data1
#field short Data2
#field short Data3
#field byte Data4 8
#endstruct
#defstruct global NETRESOURCE2W
#field int dwScope
#field int dwType
#field int dwUsage
#field int dwDisplayType
#field intptr lpLocalName
#field intptr lpRemoteName
#field intptr lpComment
#field NS_INFOA ns_info
#field GUID ServiceType
#field int dwProtocols
#field intptr lpiProtocols
#endstruct
stdim st, NETRESOURCE2W ; NSTRUCT 変数を確保
st->dwScope = 100
mes "dwScope=" + st->dwScope