home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / NETBIO.ZIP / NBSTATUS.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1990-05-03  |  3.0 KB  |  104 lines

  1. {
  2.   This routine displays information about NetBIOS, including a dump of the
  3.   NetBIOS name table. It is NOT compatible with Token Ring Hardware, just
  4.   PC-NET clones. It is compatible with many NetBIOS emulators, like the one
  5.   included with Novell and LANtastic.
  6.  
  7.   Please address questions or comments regarding this utility on Compuserve in
  8.   the PCVENB forum in section 6.
  9.  
  10.   by Richard S. Sadowsky
  11.   5/3/90
  12. }
  13. {$S-,R-,A-,V-}
  14. program NBStatus;
  15.  
  16. uses
  17.   OpString,
  18.   OpCrt,
  19.   NetBios,
  20.   NetBios2;
  21.  
  22. type
  23.   String16         = String[16];
  24.  
  25. var
  26.   Table            : PCNetAdapterTable;
  27.   N                : NCB;
  28.   Name             : NBNameStr;
  29.   Ret,Num          : Byte;
  30.  
  31. function NBName2Str(Name : NBAsciiZ) : String16;
  32.  
  33. var
  34.   S : String16;
  35. begin
  36.   Move(Name,S[1],16);
  37.   S[0] := #16;
  38.   NBName2Str := S;
  39. end;
  40.  
  41. function ParseCommandString(Index : Byte) : String;
  42. begin
  43.   ParseCommandString := ParamStr(Index);
  44. end;
  45.  
  46. procedure Report;
  47. var
  48.   I                : Word;
  49. begin
  50.   ClrScr;
  51.   WriteLn('NetBios Adapter Status Information:'^M^J);
  52.   with Table do begin
  53.     WriteLn('Self test status         = ',SelfTest);
  54.     WriteLn('Alignment errors         = ',AlignmentErrors);
  55.     WriteLn('Collisions               = ',Collisions);
  56.     WriteLn('Transmit Aborts          = ',TransmitAborts);
  57.     WriteLn('Transmits                = ',Transmits);
  58.     WriteLn('Receives                 = ',Receives);
  59.     WriteLn('Resource Depletion       = ',ResourceDepletion);
  60.     WriteLn('Free command blocks      = ',FreeCommandBlocks);
  61.     WriteLn('Current maximum NCBs     = ',CurrentMaxNCBs);
  62.     WriteLn('Hardware maximum NCBs    = ',HardwareMaxNCBs);
  63.     WriteLn('Active sessions          = ',Sessions);
  64.     WriteLn('Current max sessions     = ',CurrentMaxSessions);
  65.     WriteLn('Hardware max sessions    = ',HardwareMaxSessions);
  66.     WriteLn('Maximum packet size      = ',MaxPacketSize);
  67.     Write(^M^J'press any key to display name table (esc to abort)');
  68.     if ReadKey = ^[ then
  69.       Halt;
  70.     ClrScr;
  71.             {1                    22             37 }
  72.     WriteLn('NetBios name         name number    status');
  73.     WriteLn('============================================');
  74.     with NameTable do
  75.       for I := 1 to EntryCount do
  76.         with Entries[I] do begin
  77.           WriteLn(NBName2Str(Name),'      ',NameNum:3,'            ',
  78.                   BinaryB(Stat and $87));
  79.         end;
  80.   end;
  81. end;
  82.  
  83. begin
  84.   WriteLn('NetBios Adapter Information - version 1.0');
  85.   FillChar(Name,SizeOf(Name),0);
  86.   if ParamCount > 0 then begin
  87.  
  88.     Name := ParseCommandString(1);
  89.     Write('please wait, getting adapter status for ',Name);
  90.   end
  91.   else begin
  92.     Name := '*';
  93.     Write('please wait, getting this adapters status...');
  94.   end;
  95.   Ret := AdapterStatusPrim(Name,0,SizeOf(Table),True,Nil,N,Table);
  96.   WriteLn;
  97.   case Ret of
  98.     0 : Report;
  99.     5 : WriteLn('No such name found (failed because timeout expired)');
  100.     6 : WriteLn('Reply buffer is too small');
  101.     else WriteLn('NetBios Error = ',Ret);
  102.   end;
  103. end.
  104.