home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0040 - 0049 / ibm0040-0049 / ibm0040.tar / ibm0040 / BTF521-3.ZIP / NETBIOS.LZH / NETBIOS2.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1990-05-03  |  3.7 KB  |  127 lines

  1. {$S-,R-,I-,V-,B-,F-}
  2. {$IFNDEF Ver40}
  3.   {$F+,O+,A-}        {Allow overlays & avoid byte mismatch problems}
  4. {$ENDIF}
  5.  
  6. {*********************************************************}
  7. {*                 NETBIOS2.PAS 1.00                     *}
  8. {*********************************************************}
  9. {
  10.   Compliments the NETBIOS.PAS unit.
  11.  
  12.   This unit adds support for Network Adapter Status function call. Amoung
  13.   other things, this allows you to return the NetBios Name Table for any
  14.   active node.
  15.  
  16.   Please address questions or comments regarding this utility on Compuserve in
  17.   the PCVENB forum in section 6.
  18.  
  19.   by Richard S. Sadowsky
  20.   5/3/90
  21. }
  22. Unit NetBios2;
  23. interface
  24.  
  25. Uses
  26.   Dos,
  27.   NetBios;
  28.  
  29. const
  30.   NBAdapterStatus  = $33;
  31.   MaxTableEntries  = 64;
  32.  
  33. type
  34.   NBAsciiZ         = Array[0..15] of Char;
  35.   TableEntry       =
  36.     record
  37.       Name         : NBAsciiZ;
  38.       NameNum      : Byte;
  39.       Stat         : Byte;
  40.     end;
  41.   TableEntries     = Array[1..MaxTableEntries] of TableEntry;
  42.   NetBiosNameTable =
  43.     record
  44.       EntryCount             : Word;
  45.       Entries                : TableEntries;
  46.     end;
  47.   PCNetAdapterTable =
  48.     record
  49.       PermanentNodeName      : Array[1..6] of Char;
  50.       ExtJumbers             : Byte;
  51.       SelfTest               : Byte;
  52.       ProtocolMajor          : Byte;
  53.       ProtocolMinor          : Byte;
  54.       ReportingPeriod        : Word;
  55.       CRCCount               : Word;
  56.       AlignmentErrors        : Word;
  57.       Collisions             : Word;
  58.       TransmitAborts         : Word;
  59.       Transmits              : LongInt;
  60.       Receives               : LongInt;
  61.       Retransmits            : Word;
  62.       ResourceDepletion      : Word;
  63.       ReservedArea1          : Array[1..8] of Char;
  64.       FreeCommandBlocks      : Word;
  65.       CurrentMaxNCBs         : Word;
  66.       HardwareMaxNCBs        : Word;
  67.       ReservedArea2          : Array[1..4] of Char;
  68.       Sessions               : Word;
  69.       CurrentMaxSessions     : Word;
  70.       HardwareMaxSessions    : Word;
  71.       MaxPacketSize          : Word;
  72.       NameTable              : NetBiosNameTable;
  73.     end;
  74.  
  75. function AdapterStatusPrim(TargetName : NBNameStr;
  76.                            LanaNumber : Byte;
  77.                            ReplyBufLen : Word;
  78.                            Wait : Boolean;
  79.                            PostEvent : Pointer;
  80.                            var N : NCB;
  81.                            var ReplyBuf) : Byte;
  82.  
  83. function MaximumPacketSize : Word;
  84.   {-Returns the maximum size of a session packet (in Bytes), or zero if error}
  85.  
  86. implementation
  87.  
  88. function AdapterStatusPrim(TargetName : NBNameStr;
  89.                            LanaNumber : Byte;
  90.                            ReplyBufLen : Word;
  91.                            Wait : Boolean;
  92.                            PostEvent : Pointer;
  93.                            var N : NCB;
  94.                            var ReplyBuf) : Byte;
  95.  
  96. begin
  97.   ClearNCB(N);
  98.   with N do begin
  99.     Command := NBAdapterStatus;
  100.     if not Wait then
  101.       Command := Command + NoWait;
  102.     Move(TargetName[1],CallName,Length(TargetName));   {set the call name}
  103.     BufLen := ReplyBufLen;
  104.     Buffer := @ReplyBuf;
  105.     PostRoutine := PostEvent;           {set the post event routine}
  106.   end;
  107.   NetBiosRequest(N);
  108.   AdapterStatusPrim := N.RetCode;
  109. end;
  110.  
  111. function MaximumPacketSize : Word;
  112.   {-Returns the maximum size of a session packet (in Bytes), or zero if error}
  113. var
  114.   Table            : PCNetAdapterTable;
  115.   N                : NCB;
  116.   Name             : NBNameStr;
  117.  
  118. begin
  119.   Name := '*';
  120.   if AdapterStatusPrim(Name,0,SizeOf(Table),True,Nil,N,Table) = 0 then
  121.     MaximumPacketSize := Table.MaxPacketSize
  122.   else
  123.     MaximumPacketSize := 0;
  124. end;
  125.  
  126. end.
  127.