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

USE_INFO_2

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

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

フィールド

フィールドサイズx64x86説明
ui2_localLPWSTR8/4+0+0接続を割り当てるローカルデバイス名を表す文字列。NULL可。
ui2_remoteLPWSTR8/4+8+4接続先のリモート共有のUNCパスを表す文字列へのポインタ。
ui2_passwordLPWSTR8/4+16+8接続認証に用いるパスワードを表す文字列。NULLで省略可。
ui2_statusDWORD4+24+12接続の現在の状態を示す。USE_OK等の状態コードを保持する。
ui2_asg_typeUSE_INFO_ASG_TYPE4+28+16接続先リソースの種別を示す列挙値(ディスク/プリンタ等)。
ui2_refcountDWORD4+32+20この接続を参照している項目数を示す参照カウント。
ui2_usecountDWORD4+36+24この接続の明示的な使用回数を示すカウント。
ui2_usernameLPWSTR8/4+40+28接続に使用するユーザー名を表す文字列へのポインタ。
ui2_domainnameLPWSTR8/4+48+32接続に使用するドメイン名を表す文字列へのポインタ。

各言語での定義

#include <windows.h>

// USE_INFO_2  (x64 56 / x86 36 バイト)
typedef struct USE_INFO_2 {
    LPWSTR ui2_local;
    LPWSTR ui2_remote;
    LPWSTR ui2_password;
    DWORD ui2_status;
    USE_INFO_ASG_TYPE ui2_asg_type;
    DWORD ui2_refcount;
    DWORD ui2_usecount;
    LPWSTR ui2_username;
    LPWSTR ui2_domainname;
} USE_INFO_2;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct USE_INFO_2
{
    public IntPtr ui2_local;
    public IntPtr ui2_remote;
    public IntPtr ui2_password;
    public uint ui2_status;
    public uint ui2_asg_type;
    public uint ui2_refcount;
    public uint ui2_usecount;
    public IntPtr ui2_username;
    public IntPtr ui2_domainname;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure USE_INFO_2
    Public ui2_local As IntPtr
    Public ui2_remote As IntPtr
    Public ui2_password As IntPtr
    Public ui2_status As UInteger
    Public ui2_asg_type As UInteger
    Public ui2_refcount As UInteger
    Public ui2_usecount As UInteger
    Public ui2_username As IntPtr
    Public ui2_domainname As IntPtr
End Structure
import ctypes
from ctypes import wintypes

class USE_INFO_2(ctypes.Structure):
    _fields_ = [
        ("ui2_local", ctypes.c_void_p),
        ("ui2_remote", ctypes.c_void_p),
        ("ui2_password", ctypes.c_void_p),
        ("ui2_status", wintypes.DWORD),
        ("ui2_asg_type", wintypes.DWORD),
        ("ui2_refcount", wintypes.DWORD),
        ("ui2_usecount", wintypes.DWORD),
        ("ui2_username", ctypes.c_void_p),
        ("ui2_domainname", ctypes.c_void_p),
    ]
#[repr(C)]
pub struct USE_INFO_2 {
    pub ui2_local: *mut core::ffi::c_void,
    pub ui2_remote: *mut core::ffi::c_void,
    pub ui2_password: *mut core::ffi::c_void,
    pub ui2_status: u32,
    pub ui2_asg_type: u32,
    pub ui2_refcount: u32,
    pub ui2_usecount: u32,
    pub ui2_username: *mut core::ffi::c_void,
    pub ui2_domainname: *mut core::ffi::c_void,
}
import "golang.org/x/sys/windows"

type USE_INFO_2 struct {
	ui2_local uintptr
	ui2_remote uintptr
	ui2_password uintptr
	ui2_status uint32
	ui2_asg_type uint32
	ui2_refcount uint32
	ui2_usecount uint32
	ui2_username uintptr
	ui2_domainname uintptr
}
type
  USE_INFO_2 = record
    ui2_local: Pointer;
    ui2_remote: Pointer;
    ui2_password: Pointer;
    ui2_status: DWORD;
    ui2_asg_type: DWORD;
    ui2_refcount: DWORD;
    ui2_usecount: DWORD;
    ui2_username: Pointer;
    ui2_domainname: Pointer;
  end;
const USE_INFO_2 = extern struct {
    ui2_local: ?*anyopaque,
    ui2_remote: ?*anyopaque,
    ui2_password: ?*anyopaque,
    ui2_status: u32,
    ui2_asg_type: u32,
    ui2_refcount: u32,
    ui2_usecount: u32,
    ui2_username: ?*anyopaque,
    ui2_domainname: ?*anyopaque,
};
type
  USE_INFO_2 {.bycopy.} = object
    ui2_local: pointer
    ui2_remote: pointer
    ui2_password: pointer
    ui2_status: uint32
    ui2_asg_type: uint32
    ui2_refcount: uint32
    ui2_usecount: uint32
    ui2_username: pointer
    ui2_domainname: pointer
struct USE_INFO_2
{
    void* ui2_local;
    void* ui2_remote;
    void* ui2_password;
    uint ui2_status;
    uint ui2_asg_type;
    uint ui2_refcount;
    uint ui2_usecount;
    void* ui2_username;
    void* ui2_domainname;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; USE_INFO_2 サイズ: 36 バイト(x86)
dim st, 9    ; 4byte整数×9(構造体サイズ 36 / 4 切り上げ)
; ui2_local : LPWSTR (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; ui2_remote : LPWSTR (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; ui2_password : LPWSTR (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; ui2_status : DWORD (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; ui2_asg_type : USE_INFO_ASG_TYPE (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; ui2_refcount : DWORD (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; ui2_usecount : DWORD (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; ui2_username : LPWSTR (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; ui2_domainname : LPWSTR (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; USE_INFO_2 サイズ: 56 バイト(x64)
dim st, 14    ; 4byte整数×14(構造体サイズ 56 / 4 切り上げ)
; ui2_local : LPWSTR (+0, 8byte)  qpoke st,0,値 / qpeek(st,0)  ※IronHSPのみ。3.7/3.8は lpoke st,0,下位 : lpoke st,4,上位
; ui2_remote : LPWSTR (+8, 8byte)  qpoke st,8,値 / qpeek(st,8)  ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; ui2_password : LPWSTR (+16, 8byte)  qpoke st,16,値 / qpeek(st,16)  ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; ui2_status : DWORD (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; ui2_asg_type : USE_INFO_ASG_TYPE (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; ui2_refcount : DWORD (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; ui2_usecount : DWORD (+36, 4byte)  st.9 = 値  /  値 = st.9   (lpoke/lpeek も可)
; ui2_username : LPWSTR (+40, 8byte)  qpoke st,40,値 / qpeek(st,40)  ※IronHSPのみ。3.7/3.8は lpoke st,40,下位 : lpoke st,44,上位
; ui2_domainname : 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 USE_INFO_2
    #field intptr ui2_local
    #field intptr ui2_remote
    #field intptr ui2_password
    #field int ui2_status
    #field int ui2_asg_type
    #field int ui2_refcount
    #field int ui2_usecount
    #field intptr ui2_username
    #field intptr ui2_domainname
#endstruct

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