GetServerNames method

This method is intended for use with C/C++.

Method
short GetServerNames(
IUnknown * pNames,
short MaxNames )
Parameters
pNames
Points to an array of ArsOleNames to receive the names of the servers available for logon. The array must have at least MaxNames elements.
MaxNames
Specifies the maximum number of names to be returned.
Description
The names of the servers available for logon, up to a maximum of MaxNames, are returned in pNames. Each name is a null-terminated character string.

GetServerName or GetServerNames can be used to retrieve the server names. An application should use the one which is more convenient in its environment.

Return Value
Refer to return codes.
See Also
GetNumServers, GetServerName, and Logon methods

C/C + +

The following example retrieves the names of all servers available for logon, puts them in a ComboBox control, retrieves the chosen server, user ID, and password, and performs a logon.
 CArsOle * pArsCtrl;
 ArsOleName * pServerNames;
 CComboBox * pServersList;
 CEdit * pUserId;
 CEdit * pPassword;
 char server[ sizeof( ArsOleName ) ];
 char user[ sizeof( ArsOleName ) ];
 char password[ sizeof( ArsOleName ) ];
 short rc, j, num_servers;
 int index;
 VARIANT vari;
   .
   .
 // During dialog initialization:

 rc = pArsCtrl->GetNumServers( &vari );
 if ( rc != ARS_OLE_RC_SUCCESS )
   ERROR;
 num_servers = var.iVal;

 pServerNames = new ArsOleName[ max( num_servers, 1 ) ];
 rc = pArsCtrl->GetServerNames( (IUnknown*)pServerNames, num_servers );
 if ( rc != ARS_OLE_RC_SUCCESS )
   ERROR;

 for ( j = 0; j < num_servers; j++ )
   index = pServersList->AddString( pServerNames[j] );
 pServersList->SetCurSel( 0 );
   .
   .

  // During OK button processing:

  pServersList->GetWindowText( server, sizeof(server) );
  pUserId->GetWindowText( user, sizeof(user) );
  pPassword->GetWindowText( password, sizeof(password) );

  rc = pArsCtrl->Logon( server, user, password );
  if ( rc != ARS_OLE_RC_SUCCESS )
    ERROR;
   .
   .