OPC Studio User's Guide and Reference
BrowseServers Method (_EasyDAClient)
Example 



OpcLabs.EasyOpcClassic Assembly > OpcLabs.EasyOpc.DataAccess.ComTypes Namespace > _EasyDAClient Interface : BrowseServers Method
Name of the machine. Determines the computer to browse for OPC servers. It may be an empty string, in which case the local computer will be browsed.
Browses the specified computer and returns information about OPC (Data Access) servers found.
Syntax
'Declaration
 
<ElementsNotNullAttribute()>
<NotNullAttribute()>
Function BrowseServers( _
   ByVal location As String _
) As ServerElementCollection
'Usage
 
Dim instance As _EasyDAClient
Dim location As String
Dim value As ServerElementCollection
 
value = instance.BrowseServers(location)
[ElementsNotNull()]
[NotNull()]
ServerElementCollection BrowseServers( 
   string location
)
[ElementsNotNull()]
[NotNull()]
ServerElementCollection^ BrowseServers( 
   String^ location
) 

Parameters

location
Name of the machine. Determines the computer to browse for OPC servers. It may be an empty string, in which case the local computer will be browsed.

Return Value

The method returns a keyed collection of OpcLabs.EasyOpc.ServerElement values, each containing information about a particular OPC server found on the specified machine. The keys of the keyed collection are the server's CLSIDs.
Exceptions
ExceptionDescription
An error has occurred during application execution.
Example

COM

// This example shows how to obtain all ProgIDs of all OPC Data Access servers on the local machine.
//
// Find all latest examples here : https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

var Client = new ActiveXObject("OpcLabs.EasyOpc.DataAccess.EasyDAClient");
var ServerElements = Client.BrowseServers("")

for (var objEnum = new Enumerator(ServerElements) ; !objEnum.atEnd() ; objEnum.moveNext()) {
    var ServerElement = objEnum.item();
    WScript.Echo("ServerElements(\"" + ServerElement.UrlString + "\").ProgId: " + ServerElement.ProgId);
}
// This example shows how to obtain all ProgIDs of all OPC Data Access servers on the local machine.
//
// Find all latest examples here : https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

$Client = new COM("OpcLabs.EasyOpc.DataAccess.EasyDAClient");

try
{
    $ServerElements = $Client->BrowseServers("");
}
catch (com_exception $e)
{
    printf("*** Failure: %s\n", $e->getMessage());
    Exit();
}

foreach ($ServerElements as $ServerElement)
{
    printf("ServerElements(\"s\").ProgIds\n", $ServerElement->ClsidString, $ServerElement->ProgId);
}
# This example shows how to obtain all ProgIDs of all OPC Data Access servers on the local machine.
#
# The Python for Windows (pywin32) extensions package is needed. Install it using "pip install pypiwin32".
# CAUTION: We now recommend using Python.NET package instead. Full set of examples with Python.NET is available!
#
# Find all latest examples here : https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
import win32com.client
from pywintypes import com_error

# Instantiate the client object
client = win32com.client.Dispatch('OpcLabs.EasyOpc.DataAccess.EasyDAClient') 

# Perform the operation
try:
    serverElements = client.BrowseServers('')
except com_error as e:
    print('*** Failure: ' + e.args[2][1] + ': ' + e.args[2][2])
    exit()

# Display results
for serverElement in serverElements:
    print('ServerElements("' + serverElement.ClsidString + '"): ' + serverElement.ProgId)
Rem This example shows how to obtain all ProgIDs of all OPC Data Access servers on the local machine.
Rem
Rem Find all latest examples here : https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

Option Explicit

Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.DataAccess.EasyDAClient")
On Error Resume Next
Dim ServerElements: Set ServerElements = Client.BrowseServers("")
If Err.Number <> 0 Then
    WScript.Echo "*** Failure: " & Err.Source & ": " & Err.Description
    WScript.Quit
End If
On Error Goto 0

Dim ServerElement: For Each ServerElement In ServerElements
    WScript.Echo "ServerElements(""" & ServerElement.ClsidString & """).ProgId: " & ServerElement.ProgId
Next
Requirements

Target Platforms: .NET Framework: Windows 10 (selected versions), Windows 11 (selected versions), Windows Server 2016, Windows Server 2022; .NET: Linux, macOS, Microsoft Windows

See Also