USE_INFO_1
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ui1_local | LPWSTR | 8/4 | +0 | +0 | 共有リソースにリダイレクトされるローカルデバイス名 (例: ドライブ E や LPT1) を格納する文字列へのポインターです。定数 DEVLEN は、この文字列の最大文字数を指定します。このメンバーは NULL でもかまいません。詳細については、後述の「解説」セクションを参照してください。 _WIN32_WINNT または FORCE_UNICODE が定義されている場合、この文字列は Unicode になります。 | ||||||||||||||||
| ui1_remote | LPWSTR | 8/4 | +8 | +4 | アクセスするリモートリソースの共有名を格納する文字列へのポインターです。文字列は次の形式です。
_WIN32_WINNT または FORCE_UNICODE が定義されている場合、この文字列は Unicode になります。 | ||||||||||||||||
| ui1_password | LPWSTR | 8/4 | +16 | +8 | 特定のワークステーションとサーバーとの間でセッションを確立するために必要なパスワードを格納する文字列へのポインターです。 _WIN32_WINNT または FORCE_UNICODE が定義されている場合、この文字列は Unicode になります。 | ||||||||||||||||
| ui1_status | DWORD | 4 | +24 | +12 | 接続の状態です。この要素は NetUseAdd 関数では使用されません。次の値が定義されています。
| ||||||||||||||||
| ui1_asg_type | USE_INFO_ASG_TYPE | 4 | +28 | +16 | アクセスするリモートリソースの種類です。このメンバーには次のいずれかの値を指定できます。
| ||||||||||||||||
| ui1_refcount | DWORD | 4 | +32 | +20 | リモートリソース上で開かれているファイル、ディレクトリ、およびその他のプロセスの数です。この要素は NetUseAdd 関数では使用されません。 | ||||||||||||||||
| ui1_usecount | DWORD | 4 | +36 | +24 | そのリソースに対して確立されている明示的な接続 (ローカルデバイス名を伴うリダイレクト) または暗黙的な UNC 接続 (ローカルデバイス名を伴わないリダイレクト) の数です。 |
公式ドキュメント
<b>USE_INFO_1</b> 構造体は、ローカルデバイスと共有リソースとの間の接続に関する情報を格納します。この情報には、接続の状態と接続の種類が含まれます。
解説(Remarks)
ui1_local メンバーに NULL を指定すると、ドライブ文字やデバイスをリダイレクトせずに、サーバーに対する認証を要求します。同じ接続が有効な間にそのサーバーに対して行われる以降のリダイレクトでは、最初の NetUseAdd 関数の呼び出しで ui1_password メンバーに指定されたパスワードが使用されます。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での定義
#include <windows.h>
// USE_INFO_1 (x64 40 / x86 28 バイト)
typedef struct USE_INFO_1 {
LPWSTR ui1_local;
LPWSTR ui1_remote;
LPWSTR ui1_password;
DWORD ui1_status;
USE_INFO_ASG_TYPE ui1_asg_type;
DWORD ui1_refcount;
DWORD ui1_usecount;
} USE_INFO_1;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct USE_INFO_1
{
public IntPtr ui1_local;
public IntPtr ui1_remote;
public IntPtr ui1_password;
public uint ui1_status;
public uint ui1_asg_type;
public uint ui1_refcount;
public uint ui1_usecount;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure USE_INFO_1
Public ui1_local As IntPtr
Public ui1_remote As IntPtr
Public ui1_password As IntPtr
Public ui1_status As UInteger
Public ui1_asg_type As UInteger
Public ui1_refcount As UInteger
Public ui1_usecount As UInteger
End Structureimport ctypes
from ctypes import wintypes
class USE_INFO_1(ctypes.Structure):
_fields_ = [
("ui1_local", ctypes.c_void_p),
("ui1_remote", ctypes.c_void_p),
("ui1_password", ctypes.c_void_p),
("ui1_status", wintypes.DWORD),
("ui1_asg_type", wintypes.DWORD),
("ui1_refcount", wintypes.DWORD),
("ui1_usecount", wintypes.DWORD),
]#[repr(C)]
pub struct USE_INFO_1 {
pub ui1_local: *mut core::ffi::c_void,
pub ui1_remote: *mut core::ffi::c_void,
pub ui1_password: *mut core::ffi::c_void,
pub ui1_status: u32,
pub ui1_asg_type: u32,
pub ui1_refcount: u32,
pub ui1_usecount: u32,
}import "golang.org/x/sys/windows"
type USE_INFO_1 struct {
ui1_local uintptr
ui1_remote uintptr
ui1_password uintptr
ui1_status uint32
ui1_asg_type uint32
ui1_refcount uint32
ui1_usecount uint32
}type
USE_INFO_1 = record
ui1_local: Pointer;
ui1_remote: Pointer;
ui1_password: Pointer;
ui1_status: DWORD;
ui1_asg_type: DWORD;
ui1_refcount: DWORD;
ui1_usecount: DWORD;
end;const USE_INFO_1 = extern struct {
ui1_local: ?*anyopaque,
ui1_remote: ?*anyopaque,
ui1_password: ?*anyopaque,
ui1_status: u32,
ui1_asg_type: u32,
ui1_refcount: u32,
ui1_usecount: u32,
};type
USE_INFO_1 {.bycopy.} = object
ui1_local: pointer
ui1_remote: pointer
ui1_password: pointer
ui1_status: uint32
ui1_asg_type: uint32
ui1_refcount: uint32
ui1_usecount: uint32struct USE_INFO_1
{
void* ui1_local;
void* ui1_remote;
void* ui1_password;
uint ui1_status;
uint ui1_asg_type;
uint ui1_refcount;
uint ui1_usecount;
}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_1 サイズ: 28 バイト(x86)
dim st, 7 ; 4byte整数×7(構造体サイズ 28 / 4 切り上げ)
; ui1_local : LPWSTR (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; ui1_remote : LPWSTR (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; ui1_password : LPWSTR (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; ui1_status : DWORD (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; ui1_asg_type : USE_INFO_ASG_TYPE (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; ui1_refcount : DWORD (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; ui1_usecount : DWORD (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; USE_INFO_1 サイズ: 40 バイト(x64)
dim st, 10 ; 4byte整数×10(構造体サイズ 40 / 4 切り上げ)
; ui1_local : LPWSTR (+0, 8byte) qpoke st,0,値 / qpeek(st,0) ※IronHSPのみ。3.7/3.8は lpoke st,0,下位 : lpoke st,4,上位
; ui1_remote : LPWSTR (+8, 8byte) qpoke st,8,値 / qpeek(st,8) ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; ui1_password : LPWSTR (+16, 8byte) qpoke st,16,値 / qpeek(st,16) ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; ui1_status : DWORD (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; ui1_asg_type : USE_INFO_ASG_TYPE (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; ui1_refcount : DWORD (+32, 4byte) st.8 = 値 / 値 = st.8 (lpoke/lpeek も可)
; ui1_usecount : DWORD (+36, 4byte) st.9 = 値 / 値 = st.9 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global USE_INFO_1
#field intptr ui1_local
#field intptr ui1_remote
#field intptr ui1_password
#field int ui1_status
#field int ui1_asg_type
#field int ui1_refcount
#field int ui1_usecount
#endstruct
stdim st, USE_INFO_1 ; NSTRUCT 変数を確保
st->ui1_status = 100
mes "ui1_status=" + st->ui1_status