VB6Runtime / Library / Environment / getautoserversettings

VB6 Library Reference

GetAutoServerSettings Function Returns information about the security settings for a DCOM (Distributed Component Object Model) server.

Syntax

GetAutoServerSettings(progid, clsid, machine)

Parameters

Return Value

Returns a Long value containing security settings information for the specified DCOM server.

Remarks

Typical Uses

Basic Usage Examples

' Check DCOM server settings
Dim settings As Long
settings = GetAutoServerSettings("MyServer.Application", _
                                  "{12345678-1234-1234-1234-123456789012}", _
                                  "SERVER01")
If settings <> 0 Then
    Debug.Print "Server settings retrieved: " & settings
Else
    Debug.Print "Unable to retrieve server settings"
End If
' Verify remote component availability
Dim result As Long
result = GetAutoServerSettings("Excel.Application", _
                               "{00024500-0000-0000-C000-000000000046}", _
                               "REMOTE-PC")
If result <> 0 Then
    MsgBox "Remote Excel server is configured"
End If
' Query local server settings
Dim localSettings As Long
localSettings = GetAutoServerSettings("MyApp.Server", _
                                      "{ABCDEF01-2345-6789-ABCD-EF0123456789}", _
                                      ".")

Common Patterns

1. DCOM Server Validation

Function ValidateDCOMServer(progID As String, _
                            clsID As String, _
                            serverName As String) As Boolean
    Dim settings As Long
    On Error GoTo ErrorHandler
    settings = GetAutoServerSettings(progID, clsID, serverName)
    If settings <> 0 Then
        Debug.Print "DCOM server validated on " & serverName
        ValidateDCOMServer = True
    Else
        Debug.Print "DCOM server not accessible on " & serverName
        ValidateDCOMServer = False
    End If
    Exit Function
ErrorHandler:
    Debug.Print "Error validating DCOM server: " & Err.Description
    ValidateDCOMServer = False
End Function

2. Multi-Server Configuration Check

Sub CheckServersConfiguration()
    Dim servers() As String
    Dim i As Long
    Dim settings As Long
    servers = Array("SERVER01", "SERVER02", "SERVER03")
    For i = LBound(servers) To UBound(servers)
        settings = GetAutoServerSettings("MyApp.DataServer", _
                                         "{11111111-2222-3333-4444-555555555555}", _
                                         servers(i))
        If settings <> 0 Then
            Debug.Print servers(i) & " - Configured: " & settings
        Else
            Debug.Print servers(i) & " - Not configured"
        End If
    Next i
End Sub

Error Handling

Function SafeGetAutoServerSettings(progID As String, _
                                   clsID As String, _
                                   serverName As String) As Long
    On Error GoTo ErrorHandler
    SafeGetAutoServerSettings = GetAutoServerSettings(progID, clsID, serverName)
    Exit Function
ErrorHandler:
    Select Case Err.Number
        Case 429  ' ActiveX component can't create object
            Debug.Print "Server not available: " & serverName
        Case 462  ' Remote server machine does not exist
            Debug.Print "Machine not found: " & serverName
        Case 70   ' Permission denied
            Debug.Print "Access denied to server: " & serverName
        Case Else
            Debug.Print "Error " & Err.Number & ": " & Err.Description
    End Select
    SafeGetAutoServerSettings = 0
End Function

Common errors: - Error 429: ActiveX component can't create object - server not registered or accessible. - Error 462: Remote server machine does not exist or is unavailable. - Error 70: Permission denied - insufficient DCOM permissions. - Error 5: Invalid procedure call - invalid ProgID or CLSID format.

Limitations

Related Functions

← Back to Environment | View all functions