增加用户可以用NetUserAdd,修改用户权限可以用NetUserSetInfo !<br>这两个函数都在Netapi32.lib中申明。<br>Delphi中要自己写结构定义和函数申明。这里列出一个增加用户的例子:<br><br>function NetUserAdd(Server
WideChar;Level
WORD;Buf
ointer;ParmError:dword):LongInt;<br> stdcall; external 'netapi32.dll';<br><br>type<br> USER_INFO_1=record<br> usri1_name
widechar;<br> usri1_password
widechar;<br> usri1_password_age:dword;<br> usri1_priv:dword;<br> usri1_home_dir
widechar;<br> usri1_comment
widechar;<br> usri1_flags:dword;<br> usri1_script_path
widechar;<br> end;<br> buffer=^USER_INFO_1;<br><br>implementation<br><br>{$R *.dfm}<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br> buf:buffer;<br> error
char;<br>begin<br> GetMem(buf,sizeof(USER_INFO_1));<br> try<br> with buf^ do<br> begin<br> usri1_name:='123e';//新用户帐号<br> usri1_password:='123456789'; //新用户密码<br> usri1_password_age:=0;<br> usri1_priv:=1;<br> usri1_home_dir:=nil;<br> usri1_comment:=nil;<br> usri1_flags:=1;<br> usri1_script_path:=nil;<br> end;<br> //netuseradd(nil,1,pointer(buf),<br> ShowMessage(inttostr(NetUserAdd(nil,1,pointer(buf),0)));<br> finally<br> FreeMem(buf);<br> end;<br>end;<br><br><br>