声明部分
Option Explicit
Const NERR_Success = 0
Const ERROR_MORE_DATA = 234&
Const MAX_PREFERRED_LENGTH = -1&
Const LG_INCLUDE_INDIRECT = &H1
Const User_Priv_User = &H1
Const FORMAT_MESSAGE_FROM_SYSTEM = &H1000
Const NERR_BASE = 2100
Const MAX_NERR = NERR_BASE + 899
Const LOAD_LIBRARY_AS_DATAFILE = &H2
Const FORMAT_MESSAGE_FROM_HMODULE = &H800
Type TUser1 ’ Level 1
ptrName As Long
ptrPassword As Long
dwPasswordAge As Long
dwPriv As Long
ptrHomeDir As Long
ptrComment As Long
dwFlags As Long
ptrScriptPath As Long
End Type
Type USER_INFO_0
usri0_name As Long
End Type
Type LOCALGROUP_INFO_0
lgrpi0_name As Long
End Type
Type LOCALGROUP_USER_INFO_0
lgrui0_name As Long
End Type
Type UserInfo_1
Username As String
Password As String
PasswordAge As Long
Privilege As Long
HomeDir As String
Comment As Long
Flags As Long
ScriptPath As String
End Type
Type LOCALGROUP_MEMBERS_INFO_3
lgrmi3_domainandname As Long
End Type
Type USER_INFO_1003
usri1003_password As Long
End Type
Private Usr1 As UserInfo_1
’用户所在组
Declare Function NetUserGetLocalGroups Lib "netapi32.dll" (ByVal ServerName As String, ByVal Username As String, ByVal Level As Long, ByVal flag As Long, bufptr As Any, ByVal prefmaxlen As Long, entriesread As Long, totalentries As Long) As Long
’本地组
Declare Function NetLocalGroupEnum Lib "netapi32.dll" (ByVal ServerName As String, ByVal Level As Long, bufptr As Any, ByVal prefmaxlen As Long, entriesread As Long, totalentries As Long, resumehandle As Long) As Long
Declare Function lstrlen Lib "Kernel32.dll" Alias "lstrlenW" (ByVal lpszString As Long) As Long
Declare Function lstrcpy Lib "Kernel32.dll" Alias "lstrcpyW" (lpszString1 As Any, lpszString2 As Any) As Long
Declare Function NetApiBufferFree Lib "netapi32.dll" (ByVal Buffer As Long) As Long
Declare Sub RtlMoveMemory Lib "Kernel32.dll" (Destination As Any, Source As Any, ByVal Length As Long)
’添加用户
Private Declare Function NetUserAdd Lib "Netapi32" (ByVal ServerName As String, ByVal