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

  1. unit NTGlobalSetInfo;
  2.  
  3. interface
  4.  
  5. uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
  6.  
  7. type
  8.   TNTGlobalSetInfo = class(TComponent)
  9.   private
  10.     { Private declarations }
  11.     FServer:String;
  12.     FGroupName:String;
  13.     FName:String;
  14.     FComment:String;
  15.     FGroupID:DWORD;
  16.     FAttr: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 GroupName:String read FGroupName write FGroupName;
  25.     property Name:String read FName write FName;
  26.     property Comment:String read FComment write FComment;
  27.     property GroupID:DWORD read FGroupID write FGroupID default 0;
  28.     property Attributes:DWORD read FAttr write FAttr default 0;
  29.     function Execute:LongInt;
  30.   end;
  31.  
  32. Type GROUP_INFO_2=record
  33.     grpi2_name:LPWSTR;    grpi2_comment:LPWSTR;    grpi2_group_id:DWORD;    grpi2_attributes:DWORD;End;
  34.  
  35. function NetGroupSetInfo(Server:PWideChar;GroupName:PWideChar;Level:DWORD;Buf:PChar;ParmError:LPDWORD):LongInt; stdcall; external 'netapi32.dll';
  36.  
  37. procedure Register;
  38.  
  39. implementation
  40.  
  41. function TNTGlobalSetInfo.Execute:LongInt;
  42. var
  43.    tServer:Array[0..255] Of WideChar;
  44.    tGroup:Array[0..255] Of WideChar;
  45.    tName:Array[0..255] Of WideChar;
  46.    tComment:Array[0..255] Of WideChar;
  47.    MyInfo:GROUP_INFO_2;
  48. begin
  49.      StringToWideChar(FServer,@tServer,255);
  50.      StringToWideChar(FGroupName,@tGroup,255);
  51.      StringToWideChar(FName,@tName,255);
  52.      StringToWideChar(FComment,@tComment,255);
  53.      MyInfo.grpi2_name:=@tName;
  54.      MyInfo.grpi2_comment:=@tComment;
  55.      MyInfo.grpi2_group_id:=FGroupID;
  56.      MyInfo.grpi2_attributes:=FAttr;
  57.      Result:=NetGroupSetInfo(@tServer,@tGroup,2,@MyInfo,nil);
  58. end;
  59.  
  60. procedure Register;
  61. begin
  62.   RegisterComponents('NT Tools - Global', [TNTGlobalSetInfo]);
  63. end;
  64.  
  65. end.
  66.