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

  1. unit NTAddGlobalGroup;
  2.  
  3. interface
  4.  
  5. uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
  6.  
  7. type
  8.   TNTAddGlobalGroup = class(TComponent)
  9.   private
  10.     { Private declarations }
  11.     FServer:String;
  12.     FGroup:String;
  13.     FComment: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 Group:String read FGroup write FGroup;
  22.     property Comment:String read FComment write FComment;
  23.     function Execute:LongInt;
  24.   end;
  25.  
  26. Type GROUP_INFO_1=record
  27.     grpi1_name:LPWSTR;    grpi1_comment:LPWSTR;End;
  28.  
  29. function NetGroupAdd(ServerName:PWideChar;Level:DWORD;Buf:PChar;ParmError:LPDWORD):LongInt; stdcall; external 'netapi32.dll';
  30.  
  31. procedure Register;
  32.  
  33. implementation
  34.  
  35. function TNTAddGlobalGroup.Execute:LongInt;
  36. var
  37.    MyInfo:GROUP_INFO_1;
  38.    tComment:Array[0..255] Of WideChar;
  39.    tGroup:Array[0..255] Of WideChar;
  40.    tServer:Array[0..255] Of WideChar;
  41. begin
  42.      StringToWideChar(FServer,@tServer,255);
  43.      StringToWideChar(FComment,@tComment,255);
  44.      StringToWideChar(FGroup,@tGroup,255);
  45.      MyInfo.grpi1_name:=@tGroup;
  46.      MyInfo.grpi1_comment:=@tComment;
  47.      Result:=NetGroupAdd(@tServer,1,@MyInfo,nil);
  48. end;
  49.  
  50. procedure Register;
  51. begin
  52.   RegisterComponents('NT Tools - Global', [TNTAddGlobalGroup]);
  53. end;
  54.  
  55. end.
  56.