Search code examples
delphidelphi-2007netbios

Cannot read status of NetBIOS


We got a (reproducable) bug in our NetBIOS code in Delphi that (seemed) to work for years.

Used System Windows 7 / 64 bit.

We have a routine that checks if NetBIOS is active or not. We do this by calling NetBIOS() and reading the return code.

Even so we deactivated NetBIOS via Windows Properties on (the single enabled) Network Connection, the call to Netbios(lRec) returns NRC_GOODRET.

This is the important code fragment:

Getmem(lNCB, SizeOf(TNCB));
try
  Fillchar(lNCB^, SizeOf(TNCB), 0);

  Getmem(lLenum, SizeOf(TLanaEnum));
  try
    Fillchar(lLenum^, SizeOf(TLanaEnum), 0);

    Getmem(lAdapter, SizeOf(TAdapterStatus));
    try
      Fillchar(lAdapter^, SizeOf(TAdapterStatus), 0);

      lLenum.Length := chr(0);
      lNCB.ncb_command := chr(NCBENUM); // List NetBIOS
      lNCB.ncb_buffer := Pointer(lLenum);
      lNCB.ncb_length := SizeOf(lLenum);

      if Netbios(lNCB) = Char(NRC_GOODRET) then
        ... We get here, even when NetBIOS is deactiated

The code is unchanged and works since years. Did I miss something?


Solution

  • MSDN says Netbios is not supported on Windows 7:

    "Netbios is not supported on Windows Vista, Windows Server 2008, and subsequent versions of the operating system"