home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / NETBIO.ZIP / NETBIOS2.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1992-10-26  |  3.8 KB  |  135 lines

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