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

  1. unit NTWksUserSetInfo;
  2.  
  3. interface
  4.  
  5. uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
  6.  
  7. type
  8.   TNTWksUserSetInfo = 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. function NetWkstaUserSetInfo(Reserved:PChar;Level:DWORD;BufPtr:Pointer;Parm_Error:LPDWORD):LongInt; stdcall; external 'netapi32.dll';
  29.  
  30. Type WKSTA_USER_INFO_1=record
  31.     wkui1_username:LPWSTR;    wkui1_logon_domain:LPWSTR;    wkui1_logon_server:LPWSTR;
  32.     wkui1_oth_domains:LPWSTR;End;
  33.  
  34. procedure Register;
  35.  
  36. implementation
  37.  
  38. function TNTWksUserSetInfo.Execute:LongInt;
  39. var MyPtr:Pointer;
  40.     MyInfo:WKSTA_USER_INFO_1;
  41.     tUserName:Array[0..255] Of WideChar;
  42.     tLogonDomain:Array[0..255] Of WideChar;
  43.     tLogonServer:Array[0..255] Of WideChar;
  44.     tOther:Array[0..255] Of WideChar;
  45. begin
  46.      StringToWideChar(FUserName,@tUserName,255);
  47.      StringToWideChar(FLogonDomain,@tLogonDomain,255);
  48.      StringToWideChar(FLogonServer,@tLogonServer,255);
  49.      StringToWideChar(FOther,@tOther,255);
  50.      MyInfo.wkui1_username:=@tUserName;
  51.      MyInfo.wkui1_logon_domain:=@tLogonDomain;
  52.      MyInfo.wkui1_logon_server:=@tLogonServer;
  53.      MyInfo.wkui1_oth_domains:=@tOther;
  54.      Result:=NetWkstaUserSetInfo(nil,1,@MyPtr,nil)
  55. end;
  56.  
  57. procedure Register;
  58. begin
  59.   RegisterComponents('NT Tools - Workstation', [TNTWksUserSetInfo]);
  60. end;
  61.  
  62. end.
  63.