您的位置:首页 > 编程语言 > Delphi

delphi新建用户与用户在登录界面显示问题

2009-07-23 23:15 323 查看
delphi新建用户:

unit main;

interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, StdCtrls;

type

TForm1 = class(TForm)

Button1: TButton;

Edit1: TEdit;

procedure Button1Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

type USER_INFO_1=record

usri1_name:pwidechar;

usri1_password:pwidechar;

usri1_password_age:dword;

usri1_priv:dword;

usri1_home_dir:pwidechar;

usri1_comment:pwidechar;

usri1_flags:dword;

usri1_script_path:pwidechar;

end;

buffer=^USER_INFO_1;

var

Form1: TForm1;

implementation

{$R *.dfm}

function NetUserAdd(Server:PWideChar;Level:DWORD;Buf:pointer;ParmError:dword):LongInt;

stdcall; external 'netapi32.dll';

function NetGroupAddUser(ServerName, GroupName,
UserName:PWideChar): Integer; stdcall; external 'netapi32.dll';

function NetLocalGroupAddMembers(Server, GroupName: PWideChar; Level:Cardinal;

var MemsBuf; TotalEntries: Cardinal): Integer; stdcall; external 'netapi32.dll';

procedure TForm1.Button1Click(Sender: TObject);

var buf:buffer;

un:widestring;

error:dword;

i:integer;

begin

getmem(buf,sizeof(USER_INFO_1));

with buf^ do

begin

un:=edit1.Text+inttostr(i);

usri1_name:=pwidechar(un);

usri1_password:='123456';

usri1_password_age:=0;

usri1_priv:=1;

usri1_home_dir:=nil;

usri1_comment:=nil;

usri1_flags:=$10000;

usri1_script_path:=nil;

end;

netuseradd(nil,1,pointer(buf),0);

freemem(buf);

winexec(pchar('net localgroup users ' +edit1.Text +' /add'),sw_hide);//加权限

sleep(10);

end;

end.

========================================================

新建用户不在登录界面显示:

HKEY_LOCAL_MACHINESoftware/Microsoft/Windows NT/CurrentVersion/Winlogon/SpecialAccounts/UserList

适用范围:Windows XP

默认情况下,Windows XP会在登录界面中显示已经建立的用户账户名称。这样将方便恶意者猜测用户口令而进入系统,以下设置可隐藏特定的用户在登录界面中被显示出来。

步骤1:在注册表编辑器中查找以下子键:

HKEY_LOCAL_MACHINE/Software/Microsoft/Windows NT/CurrentVersion/Winlogon/Spe cialAccounts/UserList。

步骤2:为每一个希望被隐藏的用户新建一个"DWORD值",键名就是要被隐藏的用户名,将这些新建键值设置为0。

步骤3:重新启动Windows XP,登录界面中就看不到那些用户账户名称了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: