Ejemplo n.º 1
0
APIRET netbios_GetInfo(void)
{
  ULONG ulBytesRequired = 0;
  ULONG rc;
  PVOID pBuffer;
  ULONG ulCount;
  struct netbios_info_1* pNBI1;
  
  if (NULL == Options.pszAdapter)
  {
    printf("Please specify NetBIOS adapter name, such as 'net1'\n");
    return ERROR_INVALID_PARAMETER;
  }
  
  // determine number of available entries
  rc = NetBios32GetInfo(Options.pszServer,
                        Options.pszAdapter,
                        1,
                        NULL,
                        0,
                        &ulBytesRequired);
  /* @@@PH error handling */
    
  // if no information is available ...
  if (0 == ulBytesRequired)
  {
    printf("No information available for %s\n",
           Options.pszAdapter);
    return NO_ERROR;
  }
  
  printf("NetBIOS information for %s on %s:\n",
         (Options.pszServer == NULL) ? "(local)" : Options.pszServer,
         Options.pszAdapter);
  
  // allocate buffer of sufficient size
  pBuffer = malloc( ulBytesRequired );
  if (NULL == pBuffer)
    return ERROR_NOT_ENOUGH_MEMORY;

  // enumerate all network drivers (net1, net2, ...)
  // and build the array of LANA numbers
  rc = NetBios32GetInfo(Options.pszServer,
                        Options.pszAdapter,
                        1,
                        (PUCHAR)pBuffer,
                        ulBytesRequired,
                        &ulBytesRequired);
                        
  /* @@@PH error handling */
  
  pNBI1 = (struct netbios_info_1 *)pBuffer;
  
  printNBI(Options.pszAdapter,
           pNBI1 );
  
  free( pBuffer );
  
  return NO_ERROR;
}
Ejemplo n.º 2
0
// Get full hostname (eg. DoDo.BSn-Germany.crg.de)
bool wxGetHostName( wxChar* zBuf, int nMaxSize )
{
    if (!zBuf) return false;

#if defined(wxUSE_NET_API) && wxUSE_NET_API
    char           zServer[256];
    char           zComputer[256];
    unsigned long  ulLevel = 0;
    unsigned char* zBuffer = NULL;
    unsigned long  ulBuffer = 256;
    unsigned long* pulTotalAvail = NULL;

    NetBios32GetInfo( (const unsigned char*)zServer
                     ,(const unsigned char*)zComputer
                     ,ulLevel
                     ,zBuffer
                     ,ulBuffer
                     ,pulTotalAvail
                    );
    strcpy(zBuf, zServer);
#else
    wxChar*        zSysname;
    const wxChar*  zDefaultHost = _T("noname");

    if ((zSysname = wxGetenv(_T("SYSTEM_NAME"))) == NULL)
    {
        ::PrfQueryProfileString( HINI_PROFILE
                                ,(PSZ)WX_SECTION
                                ,(PSZ)eHOSTNAME
                                ,(PSZ)zDefaultHost
                                ,(void*)zBuf
                                ,(ULONG)nMaxSize - 1
                               );
    }
    else
    {
        wxStrncpy(zBuf, zSysname, nMaxSize - 1);
    }

    zBuf[nMaxSize] = _T('\0');
#endif

    return *zBuf ? true : false;
}