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

  1. unit NTWksGetInfo;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
  7.  
  8. type
  9.   TNTWksGetInfo = class(TComponent)
  10.   private
  11.     { Private declarations }
  12.     FServer:String;
  13.     FPlatform:DWORD;
  14.     FComputerName:String;
  15.     FLanGroup:String;
  16.     FMajor:DWORD;
  17.     FMinor:DWORD;
  18.     FLanRoot:String;
  19.     FUsers:DWORD;
  20.   protected
  21.     { Protected declarations }
  22.   public
  23.     { Public declarations }
  24.   published
  25.     { Published declarations }
  26.     property Server:String read FServer write FServer;
  27.     property PlatformID:DWORD read FPlatform;
  28.     property ComputerName:String read FComputerName;
  29.     property LanGroup:String read FLanGroup;
  30.     property VersionMajor:DWORD read FMajor;
  31.     property VersionMinor:DWORD read FMinor;
  32.     property LanRoot:String read FLanRoot;
  33.     property LoggedOnUsers:DWORD read FUsers;
  34.     function Execute:LongInt;
  35.   end;
  36.  
  37. Type WKSTA_INFO_102=record
  38.     wki102_platform_id:DWORD;    wki102_computername:LPWSTR;    wki102_langroup:LPWSTR;    wki102_ver_major:DWORD;    wki102_ver_minor:DWORD;    wki102_lanroot:LPWSTR;    wki102_logged_on_users:DWORD;End;
  39.  
  40. function NetWkstaGetInfo(Server:PChar;Level:DWORD;BufPtr:Pointer):LongInt; stdcall; external 'netapi32.dll';
  41.  
  42. procedure Register;
  43.  
  44. implementation
  45.  
  46. function TNTWksGetInfo.Execute:LongInt;
  47. var
  48.    tServer:Array[0..255] Of WideChar;
  49.    MyPtr:Pointer;
  50.    MyInfo:WKSTA_INFO_102;
  51. begin
  52.      StringToWideChar(FServer,@tServer,255);
  53.      Result:=NetWkstaGetInfo(@tServer,102,@MyPtr);
  54.      If MyPtr<>nil Then
  55.      Begin
  56.           MyInfo:=WKSTA_INFO_102(MyPtr^);
  57.           FPlatform:=MyInfo.wki102_platform_id;
  58.           FComputerName:=WideCharToString(MyInfo.wki102_computername);
  59.           FLanGroup:=WideCharToString(MyInfo.wki102_langroup);
  60.           FMajor:=MyInfo.wki102_ver_major;
  61.           FMinor:=MyInfo.wki102_ver_minor;
  62.           FLanRoot:=WideCharToString(MyInfo.wki102_lanroot);
  63.           FUsers:=MyInfo.wki102_logged_on_users;
  64.      End;
  65. end;
  66.  
  67. procedure Register;
  68. begin
  69.   RegisterComponents('NT Tools - Workstation', [TNTWksGetInfo]);
  70. end;
  71.  
  72. end.
  73.