如何使用windowsAPI在系统中添加一个用户?(100分)

  • 主题发起人 主题发起人 hippoGao
  • 开始时间 开始时间
H

hippoGao

Unregistered / Unconfirmed
GUEST, unregistred user!
急,多谢<br>使用windowsAPI<br>但是不是shellexecute("net user add ...");这样的语句
 
winexec('net user &nbsp;username password /add ' ,0)
 
type<br>&nbsp; USER_INFO_1 = record<br>&nbsp; &nbsp; usri1_name: PWideChar;<br>&nbsp; &nbsp; usri1_password: PWideChar;<br>&nbsp; &nbsp; usri1_password_age: DWORD;<br>&nbsp; &nbsp; usri1_priv: DWORD;<br>&nbsp; &nbsp; usri1_home_dir: PWideChar;<br>&nbsp; &nbsp; usri1_comment: PWideChar;<br>&nbsp; &nbsp; usri1_flags: DWORD;<br>&nbsp; &nbsp; usri1_script_path: PWideChar;<br>&nbsp; end;<br>&nbsp; uBuf1 = ^USER_INFO_1;<br><br>function NetUserAdd(<br>&nbsp; Server: PWideChar;<br>&nbsp; Level: DWORD;<br>&nbsp; Buf: pointer;<br>&nbsp; ParmError: dword): Longint; stdcall; external 'netapi32.dll';<br><br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br>&nbsp; buf:uBuf1; <br>begin<br>&nbsp; GetMem(buf,sizeof(USER_INFO_1));<br>&nbsp; try<br>&nbsp; &nbsp; with buf^ do<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; usri1_name:='123e';//新用户帐号<br>&nbsp; &nbsp; &nbsp; usri1_password:='123456789'; //新用户密码<br>&nbsp; &nbsp; &nbsp; usri1_password_age:=0;<br>&nbsp; &nbsp; &nbsp; usri1_priv:=1;<br>&nbsp; &nbsp; &nbsp; usri1_home_dir:=nil;<br>&nbsp; &nbsp; &nbsp; usri1_comment:=nil;<br>&nbsp; &nbsp; &nbsp; usri1_flags:=1;<br>&nbsp; &nbsp; &nbsp; usri1_script_path:=nil;<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp;netuseradd(nil,1,pointer(buf));<br>&nbsp; finally<br>&nbsp; &nbsp; FreeMem(buf);<br>&nbsp; end;<br>
 
后退
顶部