USER_INFO_1
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| usri1_name | LPWSTR | 8/4 | +0 | +0 | ユーザー アカウントの名前を指定する Unicode 文字列へのポインターです。 NetUserSetInfo 関数では、このメンバーは無視されます。詳細については、後述の「解説」セクションを参照してください。 | ||||||||||||||||||||||||||||||||
| usri1_password | LPWSTR | 8/4 | +8 | +4 | usri1_name メンバーで示されるユーザーのパスワードを指定する Unicode 文字列へのポインターです。長さは PWLEN バイトを超えることはできません。 NetUserEnum 関数および NetUserGetInfo 関数は、パスワードのセキュリティを保つために NULL ポインターを返します。 慣例により、パスワードの長さは LM20_PWLEN 文字に制限されています。 | ||||||||||||||||||||||||||||||||
| usri1_password_age | DWORD | 4 | +16 | +8 | usri1_password メンバーが最後に変更されてから経過した秒数です。 NetUserAdd 関数および NetUserSetInfo 関数は、このメンバーを無視します。 | ||||||||||||||||||||||||||||||||
| usri1_priv | USER_PRIV | 4 | +20 | +12 | usri1_name メンバーに割り当てられた特権のレベルです。 NetUserAdd 関数を呼び出す場合、このメンバーは USER_PRIV_USER でなければなりません。 NetUserSetInfo 関数を呼び出す場合、このメンバーは NetUserGetInfo 関数または NetUserEnum 関数が返した値でなければなりません。このメンバーには次のいずれかの値を指定できます。ユーザーおよびグループのアカウント権限の詳細については、 Privileges を参照してください。
| ||||||||||||||||||||||||||||||||
| usri1_home_dir | LPWSTR | 8/4 | +24 | +16 | usri1_name メンバーで指定されたユーザーのホーム ディレクトリのパスを指定する Unicode 文字列へのポインターです。この文字列は NULL でもかまいません。 | ||||||||||||||||||||||||||||||||
| usri1_comment | LPWSTR | 8/4 | +32 | +20 | ユーザー アカウントに関連付けるコメントを含む Unicode 文字列へのポインターです。この文字列は NULL 文字列でもよく、終端の null 文字の前に任意の数の文字を含めることもできます。 | ||||||||||||||||||||||||||||||||
| usri1_flags | USER_ACCOUNT_FLAGS | 4 | +40 | +24 | このメンバーには、次の値の 1 つ以上を指定できます。 ユーザー アカウント制御フラグの設定には、特定の特権およびコントロール アクセス権が必要になる場合があることに注意してください。詳細については、NetUserSetInfo 関数の「解説」セクションを参照してください。
次の値はアカウントの種類を表します。設定できる値は 1 つだけです。 NetUserSetInfo 関数を使用してアカウントの種類を変更することはできません。 | ||||||||||||||||||||||||||||||||
| usri1_script_path | LPWSTR | 8/4 | +48 | +28 | ユーザーのログオン スクリプト ファイルのパスを指定する Unicode 文字列へのポインターです。スクリプト ファイルには、.CMD ファイル、.EXE ファイル、または .BAT ファイルを指定できます。この文字列は NULL でもかまいません。 |
公式ドキュメント
USER_INFO_1 構造体には、アカウント名、パスワード データ、特権レベル、ユーザーのホーム ディレクトリへのパスなど、ユーザー アカウントに関する情報が格納されます。
解説(Remarks)
ユーザー アカウント名は 20 文字まで、グループ名は 256 文字までに制限されています。また、アカウント名の末尾をピリオドにすることはできず、コンマや次の印字可能文字を含めることもできません: ", /, , [, ], :, |, <, >, +, =, ;, ?, *。名前には、印字不可能な 1 ~ 31 の範囲の文字も含めることはできません。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での定義
#include <windows.h>
// USER_INFO_1 (x64 56 / x86 32 バイト)
typedef struct USER_INFO_1 {
LPWSTR usri1_name;
LPWSTR usri1_password;
DWORD usri1_password_age;
USER_PRIV usri1_priv;
LPWSTR usri1_home_dir;
LPWSTR usri1_comment;
USER_ACCOUNT_FLAGS usri1_flags;
LPWSTR usri1_script_path;
} USER_INFO_1;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct USER_INFO_1
{
public IntPtr usri1_name;
public IntPtr usri1_password;
public uint usri1_password_age;
public uint usri1_priv;
public IntPtr usri1_home_dir;
public IntPtr usri1_comment;
public uint usri1_flags;
public IntPtr usri1_script_path;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure USER_INFO_1
Public usri1_name As IntPtr
Public usri1_password As IntPtr
Public usri1_password_age As UInteger
Public usri1_priv As UInteger
Public usri1_home_dir As IntPtr
Public usri1_comment As IntPtr
Public usri1_flags As UInteger
Public usri1_script_path As IntPtr
End Structureimport ctypes
from ctypes import wintypes
class USER_INFO_1(ctypes.Structure):
_fields_ = [
("usri1_name", ctypes.c_void_p),
("usri1_password", ctypes.c_void_p),
("usri1_password_age", wintypes.DWORD),
("usri1_priv", wintypes.DWORD),
("usri1_home_dir", ctypes.c_void_p),
("usri1_comment", ctypes.c_void_p),
("usri1_flags", wintypes.DWORD),
("usri1_script_path", ctypes.c_void_p),
]#[repr(C)]
pub struct USER_INFO_1 {
pub usri1_name: *mut core::ffi::c_void,
pub usri1_password: *mut core::ffi::c_void,
pub usri1_password_age: u32,
pub usri1_priv: u32,
pub usri1_home_dir: *mut core::ffi::c_void,
pub usri1_comment: *mut core::ffi::c_void,
pub usri1_flags: u32,
pub usri1_script_path: *mut core::ffi::c_void,
}import "golang.org/x/sys/windows"
type USER_INFO_1 struct {
usri1_name uintptr
usri1_password uintptr
usri1_password_age uint32
usri1_priv uint32
usri1_home_dir uintptr
usri1_comment uintptr
usri1_flags uint32
usri1_script_path uintptr
}type
USER_INFO_1 = record
usri1_name: Pointer;
usri1_password: Pointer;
usri1_password_age: DWORD;
usri1_priv: DWORD;
usri1_home_dir: Pointer;
usri1_comment: Pointer;
usri1_flags: DWORD;
usri1_script_path: Pointer;
end;const USER_INFO_1 = extern struct {
usri1_name: ?*anyopaque,
usri1_password: ?*anyopaque,
usri1_password_age: u32,
usri1_priv: u32,
usri1_home_dir: ?*anyopaque,
usri1_comment: ?*anyopaque,
usri1_flags: u32,
usri1_script_path: ?*anyopaque,
};type
USER_INFO_1 {.bycopy.} = object
usri1_name: pointer
usri1_password: pointer
usri1_password_age: uint32
usri1_priv: uint32
usri1_home_dir: pointer
usri1_comment: pointer
usri1_flags: uint32
usri1_script_path: pointerstruct USER_INFO_1
{
void* usri1_name;
void* usri1_password;
uint usri1_password_age;
uint usri1_priv;
void* usri1_home_dir;
void* usri1_comment;
uint usri1_flags;
void* usri1_script_path;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; USER_INFO_1 サイズ: 32 バイト(x86)
dim st, 8 ; 4byte整数×8(構造体サイズ 32 / 4 切り上げ)
; usri1_name : LPWSTR (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; usri1_password : LPWSTR (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; usri1_password_age : DWORD (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; usri1_priv : USER_PRIV (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; usri1_home_dir : LPWSTR (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; usri1_comment : LPWSTR (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; usri1_flags : USER_ACCOUNT_FLAGS (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; usri1_script_path : LPWSTR (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; USER_INFO_1 サイズ: 56 バイト(x64)
dim st, 14 ; 4byte整数×14(構造体サイズ 56 / 4 切り上げ)
; usri1_name : LPWSTR (+0, 8byte) qpoke st,0,値 / qpeek(st,0) ※IronHSPのみ。3.7/3.8は lpoke st,0,下位 : lpoke st,4,上位
; usri1_password : LPWSTR (+8, 8byte) qpoke st,8,値 / qpeek(st,8) ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; usri1_password_age : DWORD (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; usri1_priv : USER_PRIV (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; usri1_home_dir : LPWSTR (+24, 8byte) qpoke st,24,値 / qpeek(st,24) ※IronHSPのみ。3.7/3.8は lpoke st,24,下位 : lpoke st,28,上位
; usri1_comment : LPWSTR (+32, 8byte) qpoke st,32,値 / qpeek(st,32) ※IronHSPのみ。3.7/3.8は lpoke st,32,下位 : lpoke st,36,上位
; usri1_flags : USER_ACCOUNT_FLAGS (+40, 4byte) st.10 = 値 / 値 = st.10 (lpoke/lpeek も可)
; usri1_script_path : 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 USER_INFO_1
#field intptr usri1_name
#field intptr usri1_password
#field int usri1_password_age
#field int usri1_priv
#field intptr usri1_home_dir
#field intptr usri1_comment
#field int usri1_flags
#field intptr usri1_script_path
#endstruct
stdim st, USER_INFO_1 ; NSTRUCT 変数を確保
st->usri1_password_age = 100
mes "usri1_password_age=" + st->usri1_password_age