home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 April / Chip_2002-04_cd1.bin / zkuste / delphi / kolekce / d56 / NT.ZIP / NTComputerName.pas < prev    next >
Pascal/Delphi Source File  |  2002-01-18  |  938b  |  46 lines

  1. unit NTComputerName;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
  7.  
  8. type
  9.   TNTComputerName = class(TComponent)
  10.   private
  11.     { Private declarations }
  12.     function GetTheName:String;
  13.   protected
  14.     { Protected declarations }
  15.   public
  16.     { Public declarations }
  17.   published
  18.     { Published declarations }
  19.     property ComputerName:String read GetTheName;
  20.   end;
  21.  
  22. procedure Register;
  23.  
  24. implementation
  25.  
  26. function TNTComputerName.GetTheName:String;
  27. var TmpComputerName:Array[0..250] Of AnsiChar;
  28.     TmpComputerNameSize:DWord;
  29. begin
  30.      TmpComputerNameSize:=250;
  31.      If GetComputerName(TmpComputerName,TmpComputerNameSize) Then
  32.      Begin
  33.           Result:=StrPas(@TmpComputerName);
  34.      End Else
  35.      Begin
  36.           Result:='';
  37.      End;
  38. end;
  39.  
  40. procedure Register;
  41. begin
  42.   RegisterComponents('NT Tools - Additional', [TNTComputerName]);
  43. end;
  44.  
  45. end.
  46.