QuickOPC User's Guide and Reference
BrowseServers(IEasyDAClient) Method
Example 



OpcLabs.EasyOpcClassic Assembly > OpcLabs.EasyOpc.DataAccess Namespace > IEasyDAClientExtension Class > BrowseServers Method : BrowseServers(IEasyDAClient) Method
The client object that will perform the operation.
Browses the local computer and returns information about OPC (Data Access) servers found.
Syntax
'Declaration
 
<ExtensionAttribute()>
<ElementsNotNullAttribute()>
<NotNullAttribute()>
Public Overloads Shared Function BrowseServers( _
   ByVal client As IEasyDAClient _
) As ServerElementCollection
'Usage
 
Dim client As IEasyDAClient
Dim value As ServerElementCollection
 
value = IEasyDAClientExtension.BrowseServers(client)
[Extension()]
[ElementsNotNull()]
[NotNull()]
public static ServerElementCollection BrowseServers( 
   IEasyDAClient client
)
[Extension()]
[ElementsNotNull()]
[NotNull()]
public:
static ServerElementCollection^ BrowseServers( 
   IEasyDAClient^ client
) 

Parameters

client
The client object that will perform the operation.

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
Thrown when the OPC operation fails.
A null reference (Nothing in Visual Basic) is passed to a method that does not accept it as a valid argument.
Example
// This example shows how to obtain all ProgIDs of all OPC Data Access servers on the local machine.

using System;
using OpcLabs.EasyOpc;
using OpcLabs.EasyOpc.DataAccess;
using OpcLabs.EasyOpc.OperationModel;

namespace DocExamples.DataAccess._EasyDAClient
{
    class BrowseServers
    {
        public static void Main1()
        {
            // Instantiate the client object.
            var client = new EasyDAClient();
            ServerElementCollection serverElements;
            try
            {
                serverElements = client.BrowseServers("");
            }
            catch (OpcException opcException)
            {
                Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message);
                return;
            }

            foreach (ServerElement serverElement in serverElements)
                Console.WriteLine($"ServerElements(\"{serverElement.ClsidString}\").ProgId: {serverElement.ProgId}");
        }


        // Example output:
        //
        //ServerElements("c8a12f17-1e03-401e-b53d-6c654dd576da").ProgId: OPCLabs.KitServer.2
    }
}
// This example shows how to obtain all ProgIDs of all OPC Data Access servers on the local machine.

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.

$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);
}
Rem This example shows how to obtain all ProgIDs of all OPC Data Access servers on the local machine.

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 2012, Windows Server 2016; .NET Core, .NET 5, .NET 6: Linux, macOS, Microsoft Windows

See Also

Reference

IEasyDAClientExtension Class
IEasyDAClientExtension Members
Overload List