type<br> USER_INFO_1 = record<br> usri1_name: PWideChar;<br> usri1_password: PWideChar;<br> usri1_password_age: DWORD;<br> usri1_priv: DWORD;<br> usri1_home_dir: PWideChar;<br> usri1_comment: PWideChar;<br> usri1_flags: DWORD;<br> usri1_script_path: PWideChar;<br> end;<br> uBuf1 = ^USER_INFO_1;<br><br>function NetUserAdd(<br> Server: PWideChar;<br> Level: DWORD;<br> Buf: pointer;<br> ParmError: dword): Longint; stdcall; external 'netapi32.dll';<br><br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br> buf:uBuf1; <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> finally<br> FreeMem(buf);<br> end;<br>