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

  1. unit NTGlobalGetInfo;
  2.  
  3. interface
  4.  
  5. uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
  6.  
  7. type
  8.   TNTGlobalGetInfo = 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;
  26.     property Comment:String read FComment;
  27.     property GroupID:DWORD read FGroupID;
  28.     property Attributes:DWORD read FAttr;
  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 NetLocalGroupGetInfo(Server:PWideChar;GroupName:PWideChar;Level:DWORD;BufPtr:Pointer):LongInt; stdcall; external 'netapi32.dll';
  36.  
  37. procedure Register;
  38.  
  39. implementation
  40.  
  41. function TNTGlobalGetInfo.Execute:LongInt;
  42. var
  43.    tServer:Array[0..255] Of WideChar;
  44.    tGroup:Array[0..255] Of WideChar;
  45.    MyPtr:Pointer;
  46.    MyInfo:GROUP_INFO_2;
  47. begin
  48.      StringToWideChar(FServer,@tServer,255);
  49.      StringToWideChar(FGroupName,@tGroup,255);
  50.      Result:=NetLocalGroupGetInfo(@tServer,@tGroup,2,@MyPtr);
  51.      If MyPtr<>nil Then
  52.      Begin
  53.           MyInfo:=GROUP_INFO_2(MyPtr^);
  54.           FName:=WideCharToString(MyInfo.grpi2_name);
  55.           FComment:=WideCharToString(MyInfo.grpi2_comment);
  56.           FGroupID:=MyInfo.grpi2_group_id;
  57.           FAttr:=MyInfo.grpi2_attributes;
  58.      End;
  59. end;
  60.  
  61. procedure Register;
  62. begin
  63.   RegisterComponents('NT Tools - Global', [TNTGlobalGetInfo]);
  64. end;
  65.  
  66. end.
  67.