OpenNTF.org - Retrieve List Of Servers On Al
My Links (Not logged in)
Code Bin Search
 
Hosted by Prominic.NET
Rate This Code
5 - brilliant stuff
4 - very nice
3 - average
2 - needs work
1 - bad
   OpenNTF Code Bin
About This Code
Brief Description:
Retrieve List Of Servers On All Ports 
Rating:
Not Rated Yet 
Contributor:
Andrew Jones 
Category:
Lotusscript 
Type:
API Functions 
Last Modified:
17 Jun 2002 
OpenNTF Disclaimer

All of the program code and information presented in the OpenNTF.org Code Bin are provided "as-is", and should be used at your own risk. OpenNTF.org make no express or implied warranty about anything in the Code Bin, and OpenNTF.org will not be responsible or liable for any damage caused by the use or misuse of anything from this site. OpenNTF.org makes no guarantees about anything. Please thoroughly test all of the knowledge and code you find here before you attempt to use them in your production environment.

Code / Description

Paul Ray
23 Jun 2000, Rating --- (out of 5)


This LotusScript function makes calls to the Notes API to retrieve a list of
Domino servers from all ports. It returns a Variant containing an array of
server names in canonical format that you can iterate through to suit your
needs.

For example, to display a list of common names of all servers in a messagebox,
you can use the following button code:

Sub Click(Source As Button)
Dim n As NotesName
Dim sMsg$
Dim vServerList

' get list of servers
vServerList=GetServerList()
sMsg$="Server List:" & Chr(13) & Chr(10) & Chr(13) & Chr(10)

' loop over server list and build a string we can display

Forall s In vServerList
Set n = New NotesName(s)
sMsg$=sMsg$ & n.Common & Chr(13) & Chr(10)
End Forall

' show the list in a messagebox
Msgbox sMsg$, 0, "Server List Demo"
End Sub


Usage / Example
'Notes API declares and constants
Declare Function NSGetServerList% Lib "nnotes" (Byval dwPortName&,
nRetServerTextList%)
Declare Function ListGetText% Lib "nnotes" (Byval dwList&, Byval
nPrefixDataType%, Byval nEntryNumber%, dwRetTextPointer&, nRetTextLength%)
Declare Function OSTranslate% Lib "nnotes" (Byval nTranslateMode%, Byval
dwIn&, Byval nLength%, Byval lpszOut$, Byval nOutLength%)
Declare Function OSLockObject& Lib "nnotes" (Byval nHandle%)
Declare Function OSUnlockObject% Lib "nnotes" (Byval nHandle%)
Declare Function OSMemFree% Lib "nnotes" (Byval nHandle%)

Const OS_TRANSLATE_LMBCS_TO_NATIVE = 1
Const MAX_SERVER_NAME = 256

Function GetServerList() As Variant
Dim lpszServer$
Dim szArray() As String
Dim hList%, nStatus%, nCount%, nLength%
Dim dwList&, dwHold&

' get a list of known servers on all ports
nStatus%=NSGetServerList(0, hList%)

' be sure our API call returned a handle to our list buffer
If nStatus%=0 And hList% <> 0 Then
' initialize our results array
Redim szArray(0)

' lock down our memory handle
dwList&=OSLockObject(hList%)

Do While nStatus%=0
' get a server in the list
nStatus%=ListGetText(dwList&, 0, nCount%, dwHold&, nLength%)

If nStatus%=0 And nLength%>0 Then
' intialize the string to pass to the API
lpszServer$=Space$(nLength%)

' translate the results to the native charset
Call OSTranslate(OS_TRANSLATE_LMBCS_TO_NATIVE, dwHold&, nLength%, lpszServer$,
MAX_SERVER_NAME)

'populate an array with the results
Redim Preserve szArray(nCount)
szArray(nCount)=lpszServer$
End If

nCount=nCount+1

Loop

' free our lock on the list
Call OSUnlockObject(hList%)

' free the handle allocated by NSGetServerList
Call OSMemFree(hList%)

End If

' return results to caller
GetServerList=szArray

End Function
 Comments

No documents found

 Add your comment!