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

  1. unit NTLocalGetInfo;
  2.  
  3. interface
  4.  
  5. uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
  6.  
  7. type
  8.   TNTLocalGetInfo = class(TComponent)
  9.   private
  10.     { Private declarations }
  11.     FServer:String;
  12.     FGroup:String;
  13.     FName:String;
  14.     FComment:String;
  15.   protected
  16.     { Protected declarations }
  17.   public
  18.     { Public declarations }
  19.   published
  20.     { Published declarations }
  21.     property Server:String read FServer write FServer;
  22.     property Group:String read FGroup write FGroup;
  23.     property Name:String read FName;
  24.     property Comment:String read FComment;
  25.     function Execute:LongInt;
  26.   end;
  27.  
  28. Type LOCALGROUP_INFO_1=record
  29.     lgrpi1_name:LPWSTR;    lgrpi1_comment:LPWSTR;End;
  30.  
  31. function NetLocalGroupGetInfo(Server:PWideChar;GroupName:PWideChar;Level:DWORD;BufPtr:Pointer):LongInt; stdcall; external 'netapi32.dll';
  32.  
  33. procedure Register;
  34.  
  35. implementation
  36.  
  37. function TNTLocalGetInfo.Execute:LongInt;
  38. var
  39.    tServer:Array[0..255] Of WideChar;
  40.    tGroup:Array[0..255] Of WideChar;
  41.    MyPtr:Pointer;
  42.    MyInfo:LOCALGROUP_INFO_1;
  43. begin
  44.      StringToWideChar(FServer,@tServer,255);
  45.      StringToWideChar(FGroup,@tGroup,255);
  46.      Result:=NetLocalGroupGetInfo(@tServer,@tGroup,1,@MyPtr);
  47.      If MyPtr<>nil Then
  48.      Begin
  49.           MyInfo:=LOCALGROUP_INFO_1(MyPtr^);
  50.           FName:=WideCharToString(MyInfo.lgrpi1_name);
  51.           FComment:=WideCharToString(MyInfo.lgrpi1_comment);
  52.      End;
  53. end;
  54.  
  55. procedure Register;
  56. begin
  57.   RegisterComponents('NT Tools - Local', [TNTLocalGetInfo]);
  58. end;
  59.  
  60. end.
  61.