Win32 API 日本語リファレンス
ホームNetworkManagement.WNet › NETINFOSTRUCT

NETINFOSTRUCT

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

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

フィールド

フィールドサイズx64x86説明
cbStructureDWORD4+0+0この構造体のサイズ(バイト)。呼び出し側が設定する。
dwProviderVersionDWORD4+4+4ネットワークプロバイダーのバージョン番号。
dwStatusWIN32_ERROR4+8+8プロバイダーの状態を示すWin32エラーコード。
dwCharacteristicsNETINFOSTRUCT_CHARACTERISTICS4+12+12ネットワークの特性を示すフラグ。
dwHandleUINT_PTR8/4+16+16プロバイダー固有のハンドル値。
wNetTypeWORD2+24+20ネットワークの種類を示す値。
dwPrintersDWORD4+28+24サポートするプリンター数。-1は不明を表す。
dwDrivesDWORD4+32+28サポートするドライブ数。-1は不明を表す。

各言語での定義

#include <windows.h>

// NETINFOSTRUCT  (x64 40 / x86 32 バイト)
typedef struct NETINFOSTRUCT {
    DWORD cbStructure;
    DWORD dwProviderVersion;
    WIN32_ERROR dwStatus;
    NETINFOSTRUCT_CHARACTERISTICS dwCharacteristics;
    UINT_PTR dwHandle;
    WORD wNetType;
    DWORD dwPrinters;
    DWORD dwDrives;
} NETINFOSTRUCT;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct NETINFOSTRUCT
{
    public uint cbStructure;
    public uint dwProviderVersion;
    public uint dwStatus;
    public uint dwCharacteristics;
    public UIntPtr dwHandle;
    public ushort wNetType;
    public uint dwPrinters;
    public uint dwDrives;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure NETINFOSTRUCT
    Public cbStructure As UInteger
    Public dwProviderVersion As UInteger
    Public dwStatus As UInteger
    Public dwCharacteristics As UInteger
    Public dwHandle As UIntPtr
    Public wNetType As UShort
    Public dwPrinters As UInteger
    Public dwDrives As UInteger
End Structure
import ctypes
from ctypes import wintypes

class NETINFOSTRUCT(ctypes.Structure):
    _fields_ = [
        ("cbStructure", wintypes.DWORD),
        ("dwProviderVersion", wintypes.DWORD),
        ("dwStatus", wintypes.DWORD),
        ("dwCharacteristics", wintypes.DWORD),
        ("dwHandle", ctypes.c_size_t),
        ("wNetType", ctypes.c_ushort),
        ("dwPrinters", wintypes.DWORD),
        ("dwDrives", wintypes.DWORD),
    ]
#[repr(C)]
pub struct NETINFOSTRUCT {
    pub cbStructure: u32,
    pub dwProviderVersion: u32,
    pub dwStatus: u32,
    pub dwCharacteristics: u32,
    pub dwHandle: usize,
    pub wNetType: u16,
    pub dwPrinters: u32,
    pub dwDrives: u32,
}
import "golang.org/x/sys/windows"

type NETINFOSTRUCT struct {
	cbStructure uint32
	dwProviderVersion uint32
	dwStatus uint32
	dwCharacteristics uint32
	dwHandle uintptr
	wNetType uint16
	dwPrinters uint32
	dwDrives uint32
}
type
  NETINFOSTRUCT = record
    cbStructure: DWORD;
    dwProviderVersion: DWORD;
    dwStatus: DWORD;
    dwCharacteristics: DWORD;
    dwHandle: NativeUInt;
    wNetType: Word;
    dwPrinters: DWORD;
    dwDrives: DWORD;
  end;
const NETINFOSTRUCT = extern struct {
    cbStructure: u32,
    dwProviderVersion: u32,
    dwStatus: u32,
    dwCharacteristics: u32,
    dwHandle: usize,
    wNetType: u16,
    dwPrinters: u32,
    dwDrives: u32,
};
type
  NETINFOSTRUCT {.bycopy.} = object
    cbStructure: uint32
    dwProviderVersion: uint32
    dwStatus: uint32
    dwCharacteristics: uint32
    dwHandle: uint
    wNetType: uint16
    dwPrinters: uint32
    dwDrives: uint32
struct NETINFOSTRUCT
{
    uint cbStructure;
    uint dwProviderVersion;
    uint dwStatus;
    uint dwCharacteristics;
    size_t dwHandle;
    ushort wNetType;
    uint dwPrinters;
    uint dwDrives;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; NETINFOSTRUCT サイズ: 32 バイト(x86)
dim st, 8    ; 4byte整数×8(構造体サイズ 32 / 4 切り上げ)
; cbStructure : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; dwProviderVersion : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; dwStatus : WIN32_ERROR (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; dwCharacteristics : NETINFOSTRUCT_CHARACTERISTICS (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; dwHandle : UINT_PTR (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; wNetType : WORD (+20, 2byte)  wpoke st,20,値  /  値 = wpeek(st,20)
; dwPrinters : DWORD (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; dwDrives : DWORD (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; NETINFOSTRUCT サイズ: 40 バイト(x64)
dim st, 10    ; 4byte整数×10(構造体サイズ 40 / 4 切り上げ)
; cbStructure : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; dwProviderVersion : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; dwStatus : WIN32_ERROR (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; dwCharacteristics : NETINFOSTRUCT_CHARACTERISTICS (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; dwHandle : UINT_PTR (+16, 8byte)  qpoke st,16,値 / qpeek(st,16)  ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; wNetType : WORD (+24, 2byte)  wpoke st,24,値  /  値 = wpeek(st,24)
; dwPrinters : DWORD (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; dwDrives : DWORD (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global NETINFOSTRUCT
    #field int cbStructure
    #field int dwProviderVersion
    #field int dwStatus
    #field int dwCharacteristics
    #field intptr dwHandle
    #field short wNetType
    #field int dwPrinters
    #field int dwDrives
#endstruct

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