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

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