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

  1. unit NTWksUserGetInfo;
  2.  
  3. interface
  4.  
  5. uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
  6.  
  7. type
  8.   TNTWksUserGetInfo = class(TComponent)
  9.   private
  10.     { Private declarations }
  11.     FUserName:String;
  12.     FLogonDomain:String;
  13.     FLogonServer:String;
  14.     FOther:String;
  15.   protected
  16.     { Protected declarations }
  17.   public
  18.     { Public declarations }
  19.   published
  20.     { Published declarations }
  21.     property UserName:String read FUserName;
  22.     property LogonDomain:String read FLogonDomain;
  23.     property LogonServer:String read FLogonServer;
  24.     property OtherDomains:String read FOther;
  25.     function Execute:LongInt;
  26.   end;
  27.  
  28. Type WKSTA_USER_INFO_1=record
  29.     wkui1_username:LPWSTR;    wkui1_logon_domain:LPWSTR;    wkui1_logon_server:LPWSTR;
  30.     wkui1_oth_domains:LPWSTR;End;
  31.  
  32. function NetWkstaUserGetInfo(Reserved:PChar;Level:DWORD;BufPtr:Pointer):LongInt; stdcall; external 'netapi32.dll';
  33.  
  34. procedure Register;
  35.  
  36. implementation
  37.  
  38. function TNTWksUserGetInfo.Execute:LongInt;
  39. var MyPtr:Pointer;
  40.     MyInfo:WKSTA_USER_INFO_1;
  41. begin
  42.      Result:=NetWkstaUserGetInfo(nil,1,@MyPtr);
  43.      If MyPtr<>nil Then
  44.      Begin
  45.           MyInfo:=WKSTA_USER_INFO_1(MyPtr^);
  46.           FUserName:=WideCharToString(MyInfo.wkui1_username);
  47.           FLogonDomain:=WideCharToString(MyInfo.wkui1_logon_domain);
  48.           FLogonServer:=WideCharToString(MyInfo.wkui1_logon_server);
  49.           FOther:=WideCharToString(MyInfo.wkui1_oth_domains);
  50.      End;
  51. end;
  52.  
  53. procedure Register;
  54. begin
  55.      RegisterComponents('NT Tools - Workstation', [TNTWksUserGetInfo]);
  56. end;
  57.  
  58. end.
  59.