怎样编程在Windows2000中增加用户和改变用户权限。(100分)

  • 主题发起人 主题发起人 liaolion
  • 开始时间 开始时间
L

liaolion

Unregistered / Unconfirmed
GUEST, unregistred user!
怎样编程在Windows2000中增加用户和改变用户权限。
 
增加用户可以用NetUserAdd,修改用户权限可以用NetUserSetInfo !<br>这两个函数都在Netapi32.lib中申明。<br>Delphi中要自己写结构定义和函数申明。这里列出一个增加用户的例子:<br><br>function NetUserAdd(Server:PWideChar;Level:DWORD;Buf:pointer;ParmError:dword):LongInt;<br>&nbsp; &nbsp;stdcall; external 'netapi32.dll';<br><br>type<br>&nbsp; USER_INFO_1=record<br>&nbsp; &nbsp; &nbsp; &nbsp;usri1_name:pwidechar;<br>&nbsp; &nbsp; &nbsp; &nbsp;usri1_password:pwidechar;<br>&nbsp; &nbsp; &nbsp; &nbsp;usri1_password_age:dword;<br>&nbsp; &nbsp; &nbsp; &nbsp;usri1_priv:dword;<br>&nbsp; &nbsp; &nbsp; &nbsp;usri1_home_dir:pwidechar;<br>&nbsp; &nbsp; &nbsp; &nbsp;usri1_comment:pwidechar;<br>&nbsp; &nbsp; &nbsp; &nbsp;usri1_flags:dword;<br>&nbsp; &nbsp; &nbsp; &nbsp;usri1_script_path:pwidechar;<br>&nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; buffer=^USER_INFO_1;<br><br>implementation<br><br>{$R *.dfm}<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br>&nbsp; buf:buffer;<br>&nbsp; error:pchar;<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; //netuseradd(nil,1,pointer(buf),<br>&nbsp; &nbsp; ShowMessage(inttostr(NetUserAdd(nil,1,pointer(buf),0)));<br>&nbsp; finally<br>&nbsp; &nbsp; FreeMem(buf);<br>&nbsp; end;<br>end;<br><br><br>
 
后退
顶部