PRB: GetAddressByName() Returns ERROR_FILE_NOT_FOUND

ID: Q185725

The information in this article applies to:

SYMPTOMS

The Winsock API GetAddressByName() fails with error 2 (ERROR_FILE_NOT_FOUND) when trying to obtain information on a particular service.

CAUSE

This only occurs on computers with fresh installs of Windows 95 that have never had either the Microsoft TCP/IP protocol or the Microsoft Client for Netware Networks installed.

RESOLUTION

To alleviate this problem, create a registry key named ExcludedProviders under:

   HKEY_LOCAL_MACHINE\System\CurrentControlSet\control\ 
   ServiceProvider\Order\ 

Once you have created this key, there will be the following default string pair:

   (Default)=(value not set)

Click on (Default), and then right-click to choose modify. A dialog box where you can change the value data appears. Make sure that the value data field is totally empty, and then click OK. The new value pair will look as follows:

   (Default)=""

STATUS

Microsoft is researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

Sample Code

The following code attempts to find information on a Netware File Server Service. The call to GetAddressByName() will fail with error 2 if you meet the criteria mentioned previously.

   #include <stdio.h>
   #include <winsock2.h>
   #include <nspapi.h>
   #include <svcguid.h>
   #include <wsipx.h>

   int main (int argc, char **argv)
   {
      WSADATA     WSAData;
      INT         protocols[1],
                  i,
                  err;
      char        buffer[2048];
      DWORD       bytesRequired;
      SOCKET      s;
      LPSTR       ServiceTypeName=NULL;

      char        szServerName[100];
      PCSADDR_INFO csaddrInfo;

      if (WSAStartup( MAKEWORD(2,0), &WSAData))
      {
          printf( "WSAStartup error\n" );
          return -1;
      }
      GUID ServiceType = SVCID_FILE_SERVER;
      /*
       * Service Name advertised on NetWare server
       */ 
      ServiceTypeName = argv[1];
      protocols[0]    = NSPROTO_IPX;
      bytesRequired   = sizeof(buffer);

      err = GetAddressByName(
              NS_SAP,
              &ServiceType,
              ServiceTypeName,
              protocols,
              RES_SOFT_SEARCH,
              NULL,
              buffer,
              &bytesRequired,
              NULL,
              NULL
              );
      if (err < 0)
      {
          err = GetLastError();
          printf("GetAddressByName error: %d\n", err);
          return 1;
      }
      else if (err == 0)
      {
          printf("GetAddressByName: no service found.\n");
          return 1;
      }
      WSACleanup()
      return 0;
   }

Additional query words: Netware GetAddressByName
Keywords          : kbnetwork kbAPI kbSDKPlatform kbWinOS95 kbWinsock kbGrpNet 
Issue type        : kbprb
Solution Type     : kbpending

Last Reviewed: July 31, 1998