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

  1. unit NTAddGlobalUser;
  2.  
  3. interface
  4.  
  5. uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
  6.  
  7. type
  8.   TNTAddGlobalUser = class(TComponent)
  9.   private
  10.     { Private declarations }
  11.     FServer:String;
  12.     FGroup:String;
  13.     FUserName:String;
  14.   protected
  15.     { Protected declarations }
  16.   public
  17.     { Public declarations }
  18.   published
  19.     { Published declarations }
  20.     property Server:String read FServer write FServer;
  21.     property UserName:String read FUserName write FUserName;
  22.     property Group:String read FGroup write FGroup;
  23.     function Execute:LongInt;
  24.   end;
  25.  
  26. function NetGroupAddUser(ServerName:PWideChar;GroupName:PWideChar;UserName:PWideChar):LongInt; stdcall; external 'netapi32.dll';
  27.  
  28. procedure Register;
  29.  
  30. implementation
  31.  
  32. function TNTAddGlobalUser.Execute:LongInt;
  33. var
  34.    tServer:Array[0..255] Of WideChar;
  35.    tUser:Array[0..255] Of WideChar;
  36.    tGroup:Array[0..255] Of WideChar;
  37. begin
  38.      StringToWideChar(FServer,@tServer,255);
  39.      StringToWideChar(FUserName,@tUser,255);
  40.      StringToWideChar(FGroup,@tGroup,255);
  41.      Result:=NetGroupAddUser(@tServer,@tGroup,@tUser);
  42. end;
  43.  
  44. procedure Register;
  45. begin
  46.   RegisterComponents('NT Tools - Global', [TNTAddGlobalUser]);
  47. end;
  48.  
  49. end.
  50.