home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 April / Chip_2002-04_cd1.bin / zkuste / delphi / kolekce / d56 / NT.ZIP / NTSetUserInfo.pas < prev    next >
Pascal/Delphi Source File  |  1999-08-04  |  2KB  |  66 lines

  1. unit NTSetUserInfo;
  2.  
  3. interface
  4.  
  5. uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
  6.  
  7. type
  8.   TNTSetUserInfo = class(TComponent)
  9.   private
  10.     { Private declarations }
  11.     FUserName:String;
  12.     FServer:String;
  13.     FFullName:String;
  14.     FComment:String;
  15.     FFlags:DWORD;
  16.     FUserID:DWORD;
  17.   protected
  18.     { Protected declarations }
  19.   public
  20.     { Public declarations }
  21.   published
  22.     { Published declarations }
  23.     property Server:string read FServer write FServer;
  24.     property UserName:String read FUserName write FUserName;
  25.     property FullName:String read FFullName write FFullName;
  26.     property Comment:String read FComment write FComment;
  27.     property Flags:DWORD read FFlags write FFlags;
  28.     property UserID:DWORD read FUserID write FUserID;
  29.     function Execute:LongInt;
  30.   end;
  31.  
  32. Type USER_INFO_20=record
  33.     usri20_name:LPWSTR;    usri20_full_name:LPWSTR;    usri20_comment:LPWSTR;    usri20_flags:DWORD;    usri20_user_id:DWORD;End;
  34.  
  35. function NetUserSetInfo(Server:PWideChar;UserName:PWideChar;Level:DWORD;Buffer:PChar;ParmError:PChar):LongInt; stdcall; external 'netapi32.dll';
  36.  
  37. procedure Register;
  38.  
  39. implementation
  40.  
  41. function TNTSetUserInfo.Execute:LongInt;
  42. var TheUser:Array[0..255] Of WideChar;
  43.     TheServer:Array[0..255] Of WideChar;
  44.     TheFullName:Array[0..255] Of WideChar;
  45.     TheComment:Array[0..255] Of WideChar;
  46.     MyInfo:USER_INFO_20;
  47. begin
  48.      StringToWideChar(FUserName,@TheUser,255);
  49.      StringToWideChar(FServer,@TheServer,255);
  50.      StringToWideChar(FFullName,@TheFullName,255);
  51.      StringToWideChar(FComment,@TheComment,255);
  52.      MyInfo.usri20_name:=@TheUser;
  53.      MyInfo.usri20_full_name:=@TheFullName;
  54.      MyInfo.usri20_comment:=@TheComment;
  55.      MyInfo.usri20_flags:=FFlags;
  56.      MyInfo.usri20_user_id:=FUserID;
  57.      Result:=NetUserSetInfo(@TheServer,@TheUser,20,@MyInfo,nil);
  58. end;
  59.  
  60. procedure Register;
  61. begin
  62.   RegisterComponents('NT Tools - User Management', [TNTSetUserInfo]);
  63. end;
  64.  
  65. end.
  66.