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

SHARE_INFO_2

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

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

フィールド

フィールドサイズx64x86説明
shi2_netnameLPWSTR8/4+0+0共有リソースのネットワーク名。Unicode。
shi2_typeSHARE_TYPE4+8+4共有の種類を示す値。ディスク/プリンタ/IPC等。
shi2_remarkLPWSTR8/4+16+8共有に付与されたコメント文字列。Unicode。
shi2_permissionsSHARE_INFO_PERMISSIONS4+24+12共有レベルのアクセス権限を示すフラグ。share-levelサーバーのみ有効。
shi2_max_usesDWORD4+28+16同時接続可能な最大数。-1で無制限。
shi2_current_usesDWORD4+32+20現在の接続数。
shi2_pathLPWSTR8/4+40+24共有されるローカルパス。Unicode。
shi2_passwdLPWSTR8/4+48+28共有のパスワード。share-levelサーバーのみ有効。Unicode。

各言語での定義

#include <windows.h>

// SHARE_INFO_2  (x64 56 / x86 32 バイト)
typedef struct SHARE_INFO_2 {
    LPWSTR shi2_netname;
    SHARE_TYPE shi2_type;
    LPWSTR shi2_remark;
    SHARE_INFO_PERMISSIONS shi2_permissions;
    DWORD shi2_max_uses;
    DWORD shi2_current_uses;
    LPWSTR shi2_path;
    LPWSTR shi2_passwd;
} SHARE_INFO_2;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SHARE_INFO_2
{
    public IntPtr shi2_netname;
    public uint shi2_type;
    public IntPtr shi2_remark;
    public uint shi2_permissions;
    public uint shi2_max_uses;
    public uint shi2_current_uses;
    public IntPtr shi2_path;
    public IntPtr shi2_passwd;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure SHARE_INFO_2
    Public shi2_netname As IntPtr
    Public shi2_type As UInteger
    Public shi2_remark As IntPtr
    Public shi2_permissions As UInteger
    Public shi2_max_uses As UInteger
    Public shi2_current_uses As UInteger
    Public shi2_path As IntPtr
    Public shi2_passwd As IntPtr
End Structure
import ctypes
from ctypes import wintypes

class SHARE_INFO_2(ctypes.Structure):
    _fields_ = [
        ("shi2_netname", ctypes.c_void_p),
        ("shi2_type", wintypes.DWORD),
        ("shi2_remark", ctypes.c_void_p),
        ("shi2_permissions", wintypes.DWORD),
        ("shi2_max_uses", wintypes.DWORD),
        ("shi2_current_uses", wintypes.DWORD),
        ("shi2_path", ctypes.c_void_p),
        ("shi2_passwd", ctypes.c_void_p),
    ]
#[repr(C)]
pub struct SHARE_INFO_2 {
    pub shi2_netname: *mut core::ffi::c_void,
    pub shi2_type: u32,
    pub shi2_remark: *mut core::ffi::c_void,
    pub shi2_permissions: u32,
    pub shi2_max_uses: u32,
    pub shi2_current_uses: u32,
    pub shi2_path: *mut core::ffi::c_void,
    pub shi2_passwd: *mut core::ffi::c_void,
}
import "golang.org/x/sys/windows"

type SHARE_INFO_2 struct {
	shi2_netname uintptr
	shi2_type uint32
	shi2_remark uintptr
	shi2_permissions uint32
	shi2_max_uses uint32
	shi2_current_uses uint32
	shi2_path uintptr
	shi2_passwd uintptr
}
type
  SHARE_INFO_2 = record
    shi2_netname: Pointer;
    shi2_type: DWORD;
    shi2_remark: Pointer;
    shi2_permissions: DWORD;
    shi2_max_uses: DWORD;
    shi2_current_uses: DWORD;
    shi2_path: Pointer;
    shi2_passwd: Pointer;
  end;
const SHARE_INFO_2 = extern struct {
    shi2_netname: ?*anyopaque,
    shi2_type: u32,
    shi2_remark: ?*anyopaque,
    shi2_permissions: u32,
    shi2_max_uses: u32,
    shi2_current_uses: u32,
    shi2_path: ?*anyopaque,
    shi2_passwd: ?*anyopaque,
};
type
  SHARE_INFO_2 {.bycopy.} = object
    shi2_netname: pointer
    shi2_type: uint32
    shi2_remark: pointer
    shi2_permissions: uint32
    shi2_max_uses: uint32
    shi2_current_uses: uint32
    shi2_path: pointer
    shi2_passwd: pointer
struct SHARE_INFO_2
{
    void* shi2_netname;
    uint shi2_type;
    void* shi2_remark;
    uint shi2_permissions;
    uint shi2_max_uses;
    uint shi2_current_uses;
    void* shi2_path;
    void* shi2_passwd;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; SHARE_INFO_2 サイズ: 32 バイト(x86)
dim st, 8    ; 4byte整数×8(構造体サイズ 32 / 4 切り上げ)
; shi2_netname : LPWSTR (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; shi2_type : SHARE_TYPE (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; shi2_remark : LPWSTR (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; shi2_permissions : SHARE_INFO_PERMISSIONS (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; shi2_max_uses : DWORD (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; shi2_current_uses : DWORD (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; shi2_path : LPWSTR (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; shi2_passwd : LPWSTR (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; SHARE_INFO_2 サイズ: 56 バイト(x64)
dim st, 14    ; 4byte整数×14(構造体サイズ 56 / 4 切り上げ)
; shi2_netname : LPWSTR (+0, 8byte)  qpoke st,0,値 / qpeek(st,0)  ※IronHSPのみ。3.7/3.8は lpoke st,0,下位 : lpoke st,4,上位
; shi2_type : SHARE_TYPE (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; shi2_remark : LPWSTR (+16, 8byte)  qpoke st,16,値 / qpeek(st,16)  ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; shi2_permissions : SHARE_INFO_PERMISSIONS (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; shi2_max_uses : DWORD (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; shi2_current_uses : DWORD (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; shi2_path : LPWSTR (+40, 8byte)  qpoke st,40,値 / qpeek(st,40)  ※IronHSPのみ。3.7/3.8は lpoke st,40,下位 : lpoke st,44,上位
; shi2_passwd : LPWSTR (+48, 8byte)  qpoke st,48,値 / qpeek(st,48)  ※IronHSPのみ。3.7/3.8は lpoke st,48,下位 : lpoke st,52,上位
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global SHARE_INFO_2
    #field intptr shi2_netname
    #field int shi2_type
    #field intptr shi2_remark
    #field int shi2_permissions
    #field int shi2_max_uses
    #field int shi2_current_uses
    #field intptr shi2_path
    #field intptr shi2_passwd
#endstruct

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