QuickOPC User's Guide and Reference
_UAHostAndEndpointDialog Interface
Members  Example 



OpcLabs.EasyOpcForms Assembly > OpcLabs.EasyOpc.UA.Forms.Browsing.ComTypes Namespace : _UAHostAndEndpointDialog Interface
Exposes OpcLabs.EasyOpc.UA.Forms.Browsing.UAHostAndEndpointDialog to COM clients.
Object Model
_UAHostAndEndpointDialog InterfaceEasyUAClientSelector ClassUADiscoveryElement ClassUAEndpointDescriptor ClassHostElement Class
Syntax
'Declaration
 
<CLSCompliantAttribute(False)>
<ComVisibleAttribute(True)>
<GuidAttribute("175A791E-4BB5-4731-9EA5-7D87055FA3AE")>
<InterfaceTypeAttribute(ComInterfaceType.InterfaceIsDual)>
Public Interface _UAHostAndEndpointDialog 
'Usage
 
Dim instance As _UAHostAndEndpointDialog
[CLSCompliant(false)]
[ComVisible(true)]
[Guid("175A791E-4BB5-4731-9EA5-7D87055FA3AE")]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface _UAHostAndEndpointDialog 
[CLSCompliant(false)]
[ComVisible(true)]
[Guid("175A791E-4BB5-4731-9EA5-7D87055FA3AE")]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface class _UAHostAndEndpointDialog 
Example

COM

// This example shows how to let the user browse for a host (computer) and an endpoint of an OPC-UA server residing on it.

#include "stdafx.h"    // Includes "QuickOpc.h", and other commonly used files
#include "ShowDialog.h"

namespace _UAHostAndEndpointDialog
{
    void ShowDialog::Main()
    {
        // Initialize the COM library
        CoInitializeEx(NULL, COINIT_MULTITHREADED);
        {
            // 
            _UAHostAndEndpointDialogPtr HostAndEndpointDialogPtr(__uuidof(UAHostAndEndpointDialog));

            //
            HostAndEndpointDialogPtr->EndpointDescriptor->Host = L"opcua.demo-this.com";

            // 
            DialogResult dialogResult = HostAndEndpointDialogPtr->ShowDialog(NULL);
            _tprintf(_T("%d\n"), dialogResult);

            if (dialogResult == 1/*OK*/)
            {
                // Display results
                _HostElementPtr hostElementPtr = HostAndEndpointDialogPtr->HostElement;
                _tprintf(_T("HostElement: %s\n"), (hostElementPtr == NULL) ? _T("") : (LPCTSTR)CW2CT(hostElementPtr->ToString));
                _UADiscoveryElementPtr discoveryElementPtr = HostAndEndpointDialogPtr->DiscoveryElement;
                _tprintf(_T("DiscoveryElement: %s\n"), (discoveryElementPtr == NULL) ? _T("") : (LPCTSTR)CW2CT(discoveryElementPtr->ToString));
            }
        }
         // Release all interface pointers BEFORE calling CoUninitialize()
        CoUninitialize();
    }
}
// This example shows how to let the user browse for a host (computer) and
// an endpoint of an OPC-UA server residing on it.

class procedure ShowDialog.Main;
var
  HostAndEndpointDialog: OpcLabs_EasyOpcForms_TLB._UAHostAndEndpointDialog;
  DialogResult: System_Windows_Forms_TLB.DialogResult;
  HostElement: OpcLabs_BaseLib_TLB.HostElement;
  DiscoveryElement: OpcLabs_EasyOpcUA_TLB.UADiscoveryElement;
begin
  // Instantiate the dialog object
  HostAndEndpointDialog := CoUAHostAndEndpointDialog.Create;

  HostAndEndpointDialog.EndpointDescriptor.Host := 'opcua.demo-this.com';

  DialogResult := HostAndEndpointDialog.ShowDialog(nil);
  WriteLn(DialogResult);

  if DialogResult <> DialogResult_OK then
    Exit;

  // Display results
  HostElement := HostAndEndpointDialog.HostElement;
  if HostElement <> nil then
    WriteLn('HostElement: ', HostElement.ToString);
  DiscoveryElement := HostAndEndpointDialog.DiscoveryElement;
  if DiscoveryElement <> nil then
    WriteLn('DiscoveryElement: ', DiscoveryElement.ToString);
end;
Rem This example shows how to let the user browse for a host (computer) and an endpoint of an OPC-UA server residing on it.

Private Sub ShowDialog_Main_Command_Click()
    OutputText = ""

    Dim HostAndEndpointDialog As New UAHostAndEndpointDialog
    HostAndEndpointDialog.endpointDescriptor.Host = "opcua.demo-this.com"
    
    Dim DialogResult
    DialogResult = HostAndEndpointDialog.ShowDialog
    
    OutputText = OutputText & DialogResult & vbCrLf
    If DialogResult <> 1 Then   ' OK
        Exit Sub
    End If
    
    ' Display results
    Dim HostElement As HostElement
    Set HostElement = HostAndEndpointDialog.HostElement
    If Not HostElement Is Nothing Then
        OutputText = OutputText & "HostElement: " & HostElement & vbCrLf
    End If
    Dim DiscoveryElement As UADiscoveryElement
    Set DiscoveryElement = HostAndEndpointDialog.DiscoveryElement
    If Not DiscoveryElement Is Nothing Then
        OutputText = OutputText & "DiscoveryElement: " & DiscoveryElement & vbCrLf
    End If
End Sub
Rem This example shows how to let the user browse for a host (computer) and an endpoint of an OPC-UA server residing on it.

Option Explicit

Const DialogResult_OK = 1

Dim HostAndEndpointDialog: Set HostAndEndpointDialog = CreateObject("OpcLabs.EasyOpc.UA.Forms.Browsing.UAHostAndEndpointDialog")
HostAndEndpointDialog.EndpointDescriptor.Host = "opcua.demo-this.com"

Dim dialogResult: dialogResult = HostAndEndpointDialog.ShowDialog
WScript.Echo dialogResult

If dialogResult <> DialogResult_OK Then
    WScript.Quit
End If

' Display results
WScript.Echo "HostElement: " & HostAndEndpointDialog.HostElement
WScript.Echo "DiscoveryElement: " & HostAndEndpointDialog.DiscoveryElement
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